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

多个bean需要回调销毁方法,在for循环remove #31

Closed
NotGiveUp opened this issue Aug 19, 2022 · 6 comments
Closed

多个bean需要回调销毁方法,在for循环remove #31

NotGiveUp opened this issue Aug 19, 2022 · 6 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@NotGiveUp
Copy link

image

@DerekYRC
Copy link
Owner

@NotGiveUp 问题是?

@NotGiveUp
Copy link
Author

在for循环里 remove报错 java.util.ConcurrentModificationException

@DerekYRC
Copy link
Owner

@NotGiveUp 很奇怪,这么写理论上没有问题,日志能贴一下吗

@NotGiveUp
Copy link
Author

你搞2个bean 实现DisposableBean 跑你的test 就行;

java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1442)
at java.util.HashMap$KeyIterator.next(HashMap.java:1466)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:76)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:190)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:186)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:168)
at org.springframework.test.ioc.CircularReferenceWithProxyBeanTest.testCircularReference(CircularReferenceWithProxyBeanTest.java:23)

@DerekYRC
Copy link
Owner

@NotGiveUp get,beanNames指向disposableBeans.keySet()。有兴趣可以参考spring的做法提个pull request。
image

@DerekYRC DerekYRC added bug Something isn't working good first issue Good for newcomers labels Aug 23, 2022
@DerekYRC
Copy link
Owner

今晚修复下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants