Make span collection thread safe in message source
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
package org.springframework.cloud.sleuth.stream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.event.ClientReceivedEvent;
|
||||
@@ -45,14 +47,14 @@ public class StreamSpanListener {
|
||||
public static final String SERVER_RECV = "sr";
|
||||
public static final String SERVER_SEND = "ss";
|
||||
|
||||
private List<Span> queue = new ArrayList<>();
|
||||
private Collection<Span> queue = new ConcurrentLinkedQueue<>();
|
||||
private HostLocator endpointLocator;
|
||||
|
||||
public StreamSpanListener(HostLocator endpointLocator) {
|
||||
this.endpointLocator = endpointLocator;
|
||||
}
|
||||
|
||||
public void setQueue(List<Span> queue) {
|
||||
public void setQueue(Collection<Span> queue) {
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.stream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -42,12 +49,6 @@ import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user