diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/MilliSpan.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/MilliSpan.java index cc0a2061c..dd0b18a6e 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/MilliSpan.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/MilliSpan.java @@ -17,6 +17,7 @@ package org.springframework.cloud.sleuth; import java.util.ArrayList; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -104,4 +105,9 @@ public class MilliSpan implements Span { msg)); } + @Override + public Map getAnnotations() { + return Collections.unmodifiableMap(kVAnnotations); + } + } diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/MilliSpanTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/MilliSpanTests.java new file mode 100644 index 000000000..91fc45885 --- /dev/null +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/MilliSpanTests.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.sleuth; + +import java.util.Collections; + +import org.junit.Test; + +/** + * @author Rob Winch + */ +public class MilliSpanTests { + + + @Test(expected = UnsupportedOperationException.class) + public void getAnnotationsReadOnly() { + MilliSpan span = new MilliSpan(1, 2, "name", "traceId", Collections.emptyList(), "spanId", true, "processId"); + + span.getAnnotations().put("a", "b"); + } +} \ No newline at end of file