Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalArgumentException: negative size: -83 #5169

Open
3 tasks done
DaiChaoLi opened this issue Jul 2, 2024 · 2 comments
Open
3 tasks done

java.lang.IllegalArgumentException: negative size: -83 #5169

DaiChaoLi opened this issue Jul 2, 2024 · 2 comments

Comments

@DaiChaoLi
Copy link

DaiChaoLi commented Jul 2, 2024

描述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)

期望

简介明了地描述你希望正常情况下应该发生什么

截图

如果可以,附上截图来描述你的问题

额外的细节和日志

  • 版本:
  • 错误日志
  • 配置:
  • 平台和操作系统
@DaiChaoLi
Copy link
Author

仔细看了下,只要spring bean是多例,那么就会存在,多线程进行put和定时器线程进行remove的并发修改操作

@nobodyiam
Copy link
Member

是否能稳定复现?之前也有 issue 提及 #4800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants