- 我已经检查过 discussions
- 我已经搜索过 issues
- 我已经仔细检查过FAQ
描述bug
这里已经有相关描述 #4356
我这里一下细节,Apoll 1.9.2 Guava-31.1-jre,这个很重要,因为SpringValueRegistry在Apoll 2.1之后删了,Guava在比较低的版本没办法重现问题
复现
因为比较难复现,所以来求助社区看看有没有办法复现出来,如上描述的情形。
这里给一个触发场景大致是这样的,一般项目都会封装一个SpringBeanAwareUtil,然后getBean,多线程进行getBean中,会走这段逻辑
at com.ctrip.framework.apollo.spring.annotation.SpringValueProcessor.processField(SpringValueProcessor.java:105) at com.ctrip.framework.apollo.spring.annotation.ApolloProcessor.postProcessBeforeInitialization(ApolloProcessor.java:39) at com.ctrip.framework.apollo.spring.annotation.SpringValueProcessor.postProcessBeforeInitialization(SpringValueProcessor.java:83) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:353) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
这样就形成了,多线程在register中put,然后另外线程scanAndClean remove,最后触发
java.lang.IllegalArgumentException: negative size: -83 at com.google.common.base.Preconditions.badPositionIndex(Preconditions.java:1409) at com.google.common.base.Preconditions.checkPositionIndex(Preconditions.java:1400) at com.google.common.base.Preconditions.checkPositionIndex(Preconditions.java:1382) at com.google.common.collect.LinkedListMultimap$NodeIterator.<init>(LinkedListMultimap.java:334) at com.google.common.collect.LinkedListMultimap$1EntriesImpl.listIterator(LinkedListMultimap.java:836) at java.base/java.util.AbstractList.listIterator(AbstractList.java:311) at java.base/java.util.AbstractSequentialList.iterator(AbstractSequentialList.java:238) at com.google.common.collect.Synchronized$SynchronizedCollection.iterator(Synchronized.java:179) at com.ctrip.framework.apollo.spring.property.SpringValueRegistry.scanAndClean(SpringValueRegistry.java:87) at com.ctrip.framework.apollo.spring.property.SpringValueRegistry.access$000(SpringValueRegistry.java:36) at com.ctrip.framework.apollo.spring.property.SpringValueRegistry$1.run(SpringValueRegistry.java:75) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)
期望
简介明了地描述你希望正常情况下应该发生什么
截图
如果可以,附上截图来描述你的问题
额外的细节和日志
- 版本:
- 错误日志
- 配置:
- 平台和操作系统
6条答案
按热度按时间np8igboo1#
仔细看了下,只要spring bean是多例,那么就会存在,多线程进行put和定时器线程进行remove的并发修改操作
ppcbkaq52#
是否能稳定复现?之前也有 issue 提及 #4800
l3zydbqr3#
是否能稳定复现?之前也有 issue 提及 #4800
这个并发异常有两个的,一个是java.lang.IllegalArgumentException: negative size这种,一个是ConcurrentModificationException,但是本质上是同一个问题。发现后者是比较容易稳定复现的,前者比较难。你只需要把spring的bean搞成多例,然后多线程get bean,这样形成bean不断的在创建和销毁的情况。就比较容易观察到了,要是还是不行,我再上传demo,理论上按照我前面的描述很容易构造出demo
lf5gs5x24#
还要补充一点,就是这个多例的bean里面要有@value,不然走不到这个流程
ctzwtxfj5#
尝试了多次未能复现,是否方便上传个 demo?
8wtpewkr6#
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.