Make MilliSpan.getTimelineAnnotations read only
This commit is contained in:
@@ -40,7 +40,7 @@ public class MilliSpan implements Span {
|
||||
private List<String> parents;
|
||||
private final String spanId;
|
||||
private boolean remote = false;
|
||||
private final Map<String, String> kVAnnotations = new LinkedHashMap<>();
|
||||
private final Map<String, String> annotations = new LinkedHashMap<>();
|
||||
private final String processId;
|
||||
@Singular
|
||||
private final List<TimelineAnnotation> timelineAnnotations = new ArrayList<>();
|
||||
@@ -96,7 +96,7 @@ public class MilliSpan implements Span {
|
||||
|
||||
@Override
|
||||
public void addAnnotation(String key, String value) {
|
||||
this.kVAnnotations.put(key, value);
|
||||
this.annotations.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,7 +107,12 @@ public class MilliSpan implements Span {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAnnotations() {
|
||||
return Collections.unmodifiableMap(kVAnnotations);
|
||||
return Collections.unmodifiableMap(this.annotations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TimelineAnnotation> getTimelineAnnotations() {
|
||||
return Collections.unmodifiableList(this.timelineAnnotations);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,14 +22,22 @@ import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
public class MilliSpanTests {
|
||||
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void getAnnotationsReadOnly() {
|
||||
MilliSpan span = new MilliSpan(1, 2, "name", "traceId", Collections.<String>emptyList(), "spanId", true, "processId");
|
||||
|
||||
span.getAnnotations().put("a", "b");
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void getTimelineAnnotationsReadOnly() {
|
||||
MilliSpan span = new MilliSpan(1, 2, "name", "traceId", Collections.<String>emptyList(), "spanId", true, "processId");
|
||||
|
||||
span.getTimelineAnnotations().add(new TimelineAnnotation(1, "1"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user