Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Possible ClassCastException fix in AbstractSpanBuilder + API fixes:
Browse files Browse the repository at this point in the history
- AbstractSpanBuilder did unnecessary (and unsafe!) cast to AbstractSpan that was not necessary.
- Span implements AutoCloseable which is only available since Java7 while project delcares Java6.
   Changed to Closeable which also extends AutoCloseable and doesn't declare additional methods
   so is 100% compatible and Java6 compliant.
 - Fixed broken @see link in Reference class javadoc.
  • Loading branch information
sjoerdtalsma authored and michaelsembwever committed Dec 15, 2016
1 parent 08c4876 commit 28d8616
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* References are used by Tracer.buildSpan() to describe the relationships between Spans.
*
* @see io.opentracing.Tracer.SpanBuilder#addReference(Object, SpanContext)
* @see Tracer.SpanBuilder#addReference(String, SpanContext)
*/
public final class References {
private References(){}
Expand Down
3 changes: 2 additions & 1 deletion opentracing-api/src/main/java/io/opentracing/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
*/
package io.opentracing;

import java.io.Closeable;
import java.util.Map;

/**
* Represents an in-flight span in the opentracing system.
*
* <p>Spans are created by the {@link Tracer#buildSpan} interface.
*/
public interface Span extends AutoCloseable {
public interface Span extends Closeable {
/**
* Retrieve the associated SpanContext.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public final AbstractSpanBuilder asChildOf(Span parent) {
if (io.opentracing.NoopSpan.class.isAssignableFrom(parent.getClass())) {
return NoopSpanBuilder.INSTANCE;
} else {
withBaggageFrom((AbstractSpan) parent);
withBaggageFrom(parent.context());
return this.addReference(References.CHILD_OF, parent.context());
}
}
Expand Down Expand Up @@ -115,10 +115,10 @@ public final Iterable<Map.Entry<String, String>> baggageItems() {
@Override
public final Span start() {
AbstractSpan span = createSpan();
stringTags.entrySet().stream().forEach((entry) -> { span.setTag(entry.getKey(), entry.getValue()); });
booleanTags.entrySet().stream().forEach((entry) -> { span.setTag(entry.getKey(), entry.getValue()); });
numberTags.entrySet().stream().forEach((entry) -> { span.setTag(entry.getKey(), entry.getValue()); });
baggage.entrySet().stream().forEach((entry) -> { span.setBaggageItem(entry.getKey(), entry.getValue()); });
stringTags.entrySet().forEach((entry) -> span.setTag(entry.getKey(), entry.getValue()));
booleanTags.entrySet().forEach((entry) -> span.setTag(entry.getKey(), entry.getValue()));
numberTags.entrySet().forEach((entry) -> span.setTag(entry.getKey(), entry.getValue()));
baggage.entrySet().forEach((entry) -> span.setBaggageItem(entry.getKey(), entry.getValue()));
return span;
}

Expand Down

0 comments on commit 28d8616

Please sign in to comment.