Skip to content

Commit

Permalink
Use Iterable instead of Collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosalberto committed Nov 3, 2020
1 parent a171e0e commit 01e2341
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -42,7 +41,7 @@ public class HttpTraceContextExtractBenchmark {
private final Getter<Map<String, String>> getter =
new Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import edu.berkeley.cs.jqf.fuzz.JQF;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import java.util.Collection;
import java.util.Map;
import javax.annotation.Nullable;
import org.junit.runner.RunWith;
Expand All @@ -30,7 +29,7 @@ public void safeForRandomInputs(String baggage) {
ImmutableMap.of("baggage", baggage),
new Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.opentelemetry.api.baggage.EntryMetadata;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
Expand All @@ -24,7 +23,7 @@ class W3CBaggagePropagatorTest {
private static final Getter<Map<String, String>> getter =
new Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import edu.berkeley.cs.jqf.fuzz.JQF;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import java.util.Collection;
import java.util.Map;
import javax.annotation.Nullable;
import org.junit.runner.RunWith;
Expand All @@ -30,7 +29,7 @@ public void safeForRandomInputs(String traceParentHeader, String traceStateHeade
ImmutableMap.of("traceparent", traceParentHeader, "tracestate", traceStateHeader),
new Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import io.opentelemetry.context.propagation.TextMapPropagator.Setter;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
Expand All @@ -44,7 +43,7 @@ class HttpTraceContextTest {
private static final Getter<Map<String, String>> getter =
new Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package io.opentelemetry.context.propagation;

import io.opentelemetry.context.Context;
import java.util.Collection;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
Expand Down Expand Up @@ -122,7 +121,7 @@ interface Getter<C> {
* @param carrier carrier of propagation fields, such as an http request.
* @since 0.10.0
*/
Collection<String> keys(C carrier);
Iterable<String> keys(C carrier);

/**
* Returns the first value of the given propagation {@code key} or returns {@code null}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import io.opentelemetry.context.Context;
import io.opentelemetry.context.ContextKey;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -157,7 +156,7 @@ private static final class MapGetter implements TextMapPropagator.Getter<Map<Str
private static final MapGetter INSTANCE = new MapGetter();

@Override
public Collection<String> keys(Map<String, String> map) {
public Iterable<String> keys(Map<String, String> map) {
return map.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -96,7 +95,7 @@ public static class JaegerContextExtractBenchmark extends AbstractContextExtract
private final TextMapPropagator.Getter<Map<String, String>> getter =
new TextMapPropagator.Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down Expand Up @@ -144,7 +143,7 @@ public static class JaegerUrlEncodedContextExtractBenchmark
private final TextMapPropagator.Getter<Map<String, String>> getter =
new TextMapPropagator.Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down Expand Up @@ -192,7 +191,7 @@ public static class B3SingleHeaderContextExtractBenchmark
private final TextMapPropagator.Getter<Map<String, String>> getter =
new TextMapPropagator.Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down Expand Up @@ -243,7 +242,7 @@ private static Map<String, String> createHeaders(
private final TextMapPropagator.Getter<Map<String, String>> getter =
new TextMapPropagator.Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.opentelemetry.api.trace.TraceState;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -33,7 +32,7 @@ class AwsXRayPropagatorTest {
private static final TextMapPropagator.Getter<Map<String, String>> getter =
new TextMapPropagator.Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import io.opentelemetry.context.propagation.TextMapPropagator.Setter;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
Expand All @@ -41,7 +40,7 @@ class B3PropagatorTest {
private static final Getter<Map<String, String>> getter =
new Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import io.opentelemetry.context.propagation.TextMapPropagator.Setter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -57,7 +56,7 @@ class JaegerPropagatorTest {
private static final TextMapPropagator.Getter<Map<String, String>> getter =
new TextMapPropagator.Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import io.opentelemetry.context.propagation.TextMapPropagator.Setter;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
Expand All @@ -36,7 +35,7 @@ class OtTracerPropagatorTest {
private static final Getter<Map<String, String>> getter =
new Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapPropagator;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -39,7 +38,7 @@ class TraceMultiPropagatorTest {
private static final TextMapPropagator.Getter<Map<String, String>> getter =
new TextMapPropagator.Getter<Map<String, String>>() {
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import io.opentelemetry.context.propagation.TextMapPropagator.Setter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
Expand Down Expand Up @@ -69,7 +68,7 @@ public Object handle(Request request, Response response) {
request.raw(),
new Getter<HttpServletRequest>() {
@Override
public Collection<String> keys(HttpServletRequest carrier) {
public Iterable<String> keys(HttpServletRequest carrier) {
return Collections.list(carrier.getHeaderNames());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentracing.propagation.TextMapExtract;
import io.opentracing.propagation.TextMapInject;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -68,7 +67,7 @@ private TextMapGetter() {}

@Nullable
@Override
public Collection<String> keys(Map<String, String> carrier) {
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
import java.util.Collection;
import java.util.concurrent.ArrayBlockingQueue;
import javax.annotation.Nullable;

Expand All @@ -35,7 +34,7 @@ private void process(Message message) {
message,
new Getter<Message>() {
@Override
public Collection<String> keys(Message carrier) {
public Iterable<String> keys(Message carrier) {
return carrier.keySet();
}

Expand Down

0 comments on commit 01e2341

Please sign in to comment.