Two junit tests failed
- [x] I have searched the issues of this repository and believe that this is not a duplicate.
- [x] I have checked the FAQ of this repository and believe that this is not a duplicate.
Steps to reproduce this issue
Run AbstractMonitorFactoryTest.testMonitorFactoryGroupCache() or DubboMonitorTest.testCount() many times(may be less than 10 is enough), you will get junit test failed.
Cause Analysis
- AbstractMonitorFactoryTest.testMonitorFactoryGroupCache()
In AbstractMonitorFactory.getMonitor(), if we call thenRunAsync() first, then call FUTURES.put(),
in MonitorListener.run, FUTRUE.get() may get null, then the junit test failed.



- DubboMonitorTest.testCount()
- In DubboMonitor constructor, we starter a schedule that call
send()every 20 milliseconds!! - In
testCount(), wecollect()first, thensend(), andsend()every 20 milliseconds backend, but we will reset data insend()everytime, so let's consider this sequence: we callcollect(), and then callsend(), and before Assertions.assertEquals... , callsend()backend by the schedule to reset the statisticsMap.




I describe it in Chinese again:
这个问题是偶现的, 但是可以通过多次执行testCount()来复现(执行最多10次一般就能复现出来), 原因是, 在构造Du bboMonitor 的时候, 会启动一个定时器, 每个20毫秒来执行send()方法, 且在send()设置值以后, 就会reset 全局的statisticsMap, testCount()中考虑这么一个执行顺序: 先执行collect(), 在执行send(), 然后在执行诸多的Assertions.assertEquals之前, 可能会执行每20毫秒执行一次的send(), 在这个send()方法执行完成后, statisticsMap就会被重置, 导致junit test失败
This issue has been fixed.