Skip to content
Permalink
Browse files
change collectedStatistics type to CopyOnWriteArrayList (#377)
* change collectedStatistics type to CopyOnWriteArrayList

* CopyOnWriteArrayList could be read concurrently

* add URL not null assert
  • Loading branch information
zrlw committed Oct 9, 2021
1 parent aa74808 commit 1c9e23c9666719be62eade500eae61c1183c4d7c
Showing 2 changed files with 4 additions and 3 deletions.
@@ -20,11 +20,11 @@
import org.apache.dubbo.common.URL;
import org.apache.dubbo.monitor.MonitorService;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class MonitorServiceImpl implements MonitorService {
private List<URL> collectedStatistics = new ArrayList<>();
private List<URL> collectedStatistics = new CopyOnWriteArrayList<>();

@Override
public void collect(URL statistics) {
@@ -33,6 +33,6 @@ public void collect(URL statistics) {

@Override
public List<URL> lookup(URL query) {
return new ArrayList<>(collectedStatistics);
return collectedStatistics;
}
}
@@ -73,6 +73,7 @@ private boolean check(MonitorService service) {
boolean countConsumer = false;
System.out.println("monitor stats: " + stats.size());
for (URL stat : stats) {
Assert.assertNotNull(stat);
Assert.assertEquals("count", stat.getProtocol());
Assert.assertEquals("org.apache.dubbo.samples.monitor.api.DemoService/sayHello", stat.getPath());
if (stat.getParameter("application").equals("demo-provider")) {

0 comments on commit 1c9e23c

Please sign in to comment.