diff --git a/opentracing-api/src/main/java/io/opentracing/propagation/TextMap.java b/opentracing-api/src/main/java/io/opentracing/propagation/TextMap.java index 2e59f829..78838b6f 100644 --- a/opentracing-api/src/main/java/io/opentracing/propagation/TextMap.java +++ b/opentracing-api/src/main/java/io/opentracing/propagation/TextMap.java @@ -25,7 +25,7 @@ * @see io.opentracing.Tracer#inject(SpanContext, Format, Object) * @see io.opentracing.Tracer#extract(Format, Object) */ -public interface TextMap { +public interface TextMap extends Iterable> { /** * Gets an iterator over arbitrary key:value pairs from the TextMapReader. * @@ -36,7 +36,7 @@ public interface TextMap { * @see Format.Builtin#TEXT_MAP * @see Format.Builtin#HTTP_HEADERS */ - Iterator> getEntries(); + Iterator> iterator(); /** * Puts a key:value pair into the TextMapWriter's backing store. diff --git a/opentracing-api/src/main/java/io/opentracing/propagation/TextMapExtractAdapter.java b/opentracing-api/src/main/java/io/opentracing/propagation/TextMapExtractAdapter.java index 8c12ab70..7d547b93 100644 --- a/opentracing-api/src/main/java/io/opentracing/propagation/TextMapExtractAdapter.java +++ b/opentracing-api/src/main/java/io/opentracing/propagation/TextMapExtractAdapter.java @@ -34,7 +34,7 @@ public TextMapExtractAdapter(final Map map) { } @Override - public Iterator> getEntries() { + public Iterator> iterator() { return map.entrySet().iterator(); } diff --git a/opentracing-api/src/main/java/io/opentracing/propagation/TextMapInjectAdapter.java b/opentracing-api/src/main/java/io/opentracing/propagation/TextMapInjectAdapter.java index 5f0e7dd2..f92e6be6 100644 --- a/opentracing-api/src/main/java/io/opentracing/propagation/TextMapInjectAdapter.java +++ b/opentracing-api/src/main/java/io/opentracing/propagation/TextMapInjectAdapter.java @@ -35,7 +35,7 @@ public TextMapInjectAdapter(final Map map) { } @Override - public Iterator> getEntries() { + public Iterator> iterator() { throw new UnsupportedOperationException( "TextMapInjectAdapter should only be used with Tracer.inject()"); } diff --git a/opentracing-impl-java8/src/test/java/io/opentracing/propagation/TestTextMapExtractorImpl.java b/opentracing-impl-java8/src/test/java/io/opentracing/propagation/TestTextMapExtractorImpl.java index 3e492d99..6990ef27 100644 --- a/opentracing-impl-java8/src/test/java/io/opentracing/propagation/TestTextMapExtractorImpl.java +++ b/opentracing-impl-java8/src/test/java/io/opentracing/propagation/TestTextMapExtractorImpl.java @@ -16,14 +16,12 @@ import io.opentracing.SpanContext; import io.opentracing.TestSpanContextImpl; -import java.util.Iterator; import java.util.Map; public class TestTextMapExtractorImpl implements Extractor { public SpanContext extract(TextMap carrier) { String marker = null; - for (Iterator> iter = carrier.getEntries(); iter.hasNext();) { - Map.Entry entry = iter.next(); + for (Map.Entry entry : carrier) { if (entry.getKey().equals("test-marker")) { marker = entry.getValue(); }