Test for null in StreamSpanListener
A span can have a null name so we need to guard against it explicitly.
This commit is contained in:
@@ -106,7 +106,7 @@ public class StreamSpanListener {
|
||||
this.queue.clear();
|
||||
for (Iterator<Span> iterator = result.iterator(); iterator.hasNext();) {
|
||||
Span span = iterator.next();
|
||||
if (span.getName().equals("message/zipkin")) {
|
||||
if (span.getName() != null && span.getName().equals("message/zipkin")) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@ public class StreamSpanListenerTests {
|
||||
@Autowired
|
||||
private ZipkinTestConfiguration test;
|
||||
|
||||
@Autowired
|
||||
StreamSpanListener listener;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.test.spans.clear();
|
||||
@@ -95,6 +98,16 @@ public class StreamSpanListenerTests {
|
||||
assertEquals(2, this.test.spans.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullSpanName() {
|
||||
Trace context = this.traceManager.startSpan(null, null);
|
||||
this.application.publishEvent(new ClientSentEvent(this, context.getSpan()));
|
||||
this.traceManager.close(context);
|
||||
assertEquals(1, this.test.spans.size());
|
||||
this.listener.poll();
|
||||
assertEquals(0, this.test.spans.size());
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import({ ZipkinTestConfiguration.class, SleuthStreamAutoConfiguration.class,
|
||||
TestSupportBinderAutoConfiguration.class, ChannelBindingAutoConfiguration.class,
|
||||
@@ -110,7 +123,7 @@ public class StreamSpanListenerTests {
|
||||
|
||||
@Autowired
|
||||
StreamSpanListener listener;
|
||||
|
||||
|
||||
@ServiceActivator(inputChannel=SleuthSource.OUTPUT)
|
||||
public void handle(Message<?> msg) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user