Fix NPE on serialization with no span type (#1207)
Fix NPE on serialization with no span type
This commit is contained in:
commit
f2d8c8e6b9
|
@ -32,7 +32,11 @@ public class MsgpackFormatWriter extends FormatWriter<MessagePacker> {
|
||||||
public void writeString(final String key, final String value, final MessagePacker destination)
|
public void writeString(final String key, final String value, final MessagePacker destination)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
destination.packString(key);
|
destination.packString(key);
|
||||||
destination.packString(value);
|
if (value == null) {
|
||||||
|
destination.packNil();
|
||||||
|
} else {
|
||||||
|
destination.packString(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,6 +86,10 @@ public class MsgpackFormatWriter extends FormatWriter<MessagePacker> {
|
||||||
final String key, final BigInteger value, final MessagePacker destination)
|
final String key, final BigInteger value, final MessagePacker destination)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
destination.packString(key);
|
destination.packString(key);
|
||||||
destination.packBigInteger(value);
|
if (value == null) {
|
||||||
|
destination.packNil();
|
||||||
|
} else {
|
||||||
|
destination.packBigInteger(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ class DDSpanSerializationTest extends DDSpecification {
|
||||||
parent_id: 0l,
|
parent_id: 0l,
|
||||||
start : 100000,
|
start : 100000,
|
||||||
duration : 33000,
|
duration : 33000,
|
||||||
type : "type",
|
type : spanType,
|
||||||
error : 0,
|
error : 0,
|
||||||
metrics : metrics,
|
metrics : metrics,
|
||||||
meta : [
|
meta : [
|
||||||
|
@ -58,7 +58,7 @@ class DDSpanSerializationTest extends DDSpecification {
|
||||||
null,
|
null,
|
||||||
["a-baggage": "value"],
|
["a-baggage": "value"],
|
||||||
false,
|
false,
|
||||||
"type",
|
spanType,
|
||||||
["k1": "v1"],
|
["k1": "v1"],
|
||||||
new PendingTrace(tracer, 1G, [:]),
|
new PendingTrace(tracer, 1G, [:]),
|
||||||
tracer)
|
tracer)
|
||||||
|
@ -73,9 +73,9 @@ class DDSpanSerializationTest extends DDSpecification {
|
||||||
actualTree == expectedTree
|
actualTree == expectedTree
|
||||||
|
|
||||||
where:
|
where:
|
||||||
samplingPriority | _
|
samplingPriority | spanType
|
||||||
PrioritySampling.SAMPLER_KEEP | _
|
PrioritySampling.SAMPLER_KEEP | null
|
||||||
PrioritySampling.UNSET | _
|
PrioritySampling.UNSET | "some-type"
|
||||||
}
|
}
|
||||||
|
|
||||||
def "serialize trace/span with id #value as int"() {
|
def "serialize trace/span with id #value as int"() {
|
||||||
|
@ -93,7 +93,7 @@ class DDSpanSerializationTest extends DDSpecification {
|
||||||
null,
|
null,
|
||||||
Collections.emptyMap(),
|
Collections.emptyMap(),
|
||||||
false,
|
false,
|
||||||
"fakeType",
|
spanType,
|
||||||
Collections.emptyMap(),
|
Collections.emptyMap(),
|
||||||
new PendingTrace(tracer, 1G, [:]),
|
new PendingTrace(tracer, 1G, [:]),
|
||||||
tracer)
|
tracer)
|
||||||
|
@ -122,12 +122,12 @@ class DDSpanSerializationTest extends DDSpecification {
|
||||||
}
|
}
|
||||||
|
|
||||||
where:
|
where:
|
||||||
value | _
|
value | spanType
|
||||||
0G | _
|
0G | null
|
||||||
1G | _
|
1G | "some-type"
|
||||||
8223372036854775807G | _
|
8223372036854775807G | null
|
||||||
BigInteger.valueOf(Long.MAX_VALUE).subtract(1G) | _
|
BigInteger.valueOf(Long.MAX_VALUE).subtract(1G) | "some-type"
|
||||||
BigInteger.valueOf(Long.MAX_VALUE).add(1G) | _
|
BigInteger.valueOf(Long.MAX_VALUE).add(1G) | null
|
||||||
2G.pow(64).subtract(1G) | _
|
2G.pow(64).subtract(1G) | "some-type"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue