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:
Dave Syer
2015-12-31 15:26:35 +00:00
parent 870de624a0
commit c3ac8f570f
2 changed files with 15 additions and 2 deletions

View File

@@ -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();
}
}

View File

@@ -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) {
}