Update javadoc to allow null/empty attr values (#5616)
This commit is contained in:
parent
a781ba8fa9
commit
16e7113dcc
|
@ -91,8 +91,7 @@ public interface Span extends ImplicitContextKeyed {
|
|||
* Sets an attribute to the {@code Span}. If the {@code Span} previously contained a mapping for
|
||||
* the key, the old value is replaced by the specified value.
|
||||
*
|
||||
* <p>If a null or empty String {@code value} is passed in, the behavior is undefined, and hence
|
||||
* strongly discouraged.
|
||||
* <p>Empty String "" and null are valid attribute {@code value}, but not valid keys.
|
||||
*
|
||||
* <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
|
||||
* pre-allocate your keys, if possible.
|
||||
|
|
|
@ -578,4 +578,11 @@ class AttributesTest {
|
|||
assertThatCode(() -> myAttributesBuilder.remove(stringKey("foo"))).doesNotThrowAnyException();
|
||||
assertThatCode(() -> myAttributesBuilder.removeIf(unused -> false)).doesNotThrowAnyException();
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyValueIsValid() {
|
||||
AttributeKey<String> key = stringKey("anything");
|
||||
Attributes attributes = Attributes.of(key, "");
|
||||
assertThat(attributes.get(key)).isEqualTo("");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue