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

Concurrent registration/iteration in PropertySourcesPropertyResolver [SPR-12428] #17034

Closed
spring-projects-issues opened this issue Nov 12, 2014 · 1 comment
Assignees
Labels
status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 12, 2014

Spencer Gibb opened SPR-12428 and commented

While trying to call PropertySourcesPropertyResolver.containsProperty from one thread, another thread has added a new PropertySource and then the ConcurrentModificationException is thrown.

This code in Spring Boot adds the property source in a ContextRefreshedEvent handler. https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java#L228

[2014-11-12 15:30:35.201] boot - 93750 ERROR [Thread-3] --- ConcurrentMapConfiguration: Error firing configuration event
java.util.ConcurrentModificationException
    at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:953)
    at java.util.LinkedList$ListItr.next(LinkedList.java:886)
    at org.springframework.core.env.PropertySourcesPropertyResolver.containsProperty(PropertySourcesPropertyResolver.java:49)
    at org.springframework.core.env.AbstractEnvironment.containsProperty(AbstractEnvironment.java:460)
    at org.springframework.cloud.netflix.archaius.ConfigurableEnvironmentConfiguration.containsKey(ConfigurableEnvironmentConfiguration.java:43)
    at com.netflix.config.ConcurrentCompositeConfiguration.getSource(ConcurrentCompositeConfiguration.java:864)
    at com.netflix.config.ConcurrentCompositeConfiguration$1.configurationChanged(ConcurrentCompositeConfiguration.java:151)
    at com.netflix.config.ConcurrentMapConfiguration.fireEvent(ConcurrentMapConfiguration.java:312)
    at com.netflix.config.ConcurrentMapConfiguration.setProperty(ConcurrentMapConfiguration.java:216)
    at com.netflix.config.ConcurrentCompositeConfiguration.setProperty(ConcurrentCompositeConfiguration.java:486)
    at com.netflix.eureka.cluster.PeerEurekaNode.getBatcher(PeerEurekaNode.java:806)
    at com.netflix.eureka.cluster.PeerEurekaNode.<init>(PeerEurekaNode.java:94)
    at com.netflix.eureka.PeerAwareInstanceRegistry.updatePeerEurekaNodes(PeerAwareInstanceRegistry.java:219)
    at com.netflix.eureka.PeerAwareInstanceRegistry.setupPeerEurekaNodes(PeerAwareInstanceRegistry.java:187)
    at com.netflix.eureka.PeerAwareInstanceRegistry.init(PeerAwareInstanceRegistry.java:156)
    at com.netflix.eureka.PeerAwareInstanceRegistry.<init>(PeerAwareInstanceRegistry.java:144)
    at com.netflix.eureka.PeerAwareInstanceRegistry.<clinit>(PeerAwareInstanceRegistry.java:130)
    at org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration$RegistryInstanceProxyInitializer.onApplicationEvent(EurekaServerInitializerConfiguration.java:174)
    at org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration$RegistryInstanceProxyInitializer.onApplicationEvent(EurekaServerInitializerConfiguration.java:156)
    at org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration$RegistryInstanceProxyInitializer$$EnhancerBySpringCGLIB$$e403e8f8.onApplicationEvent(<generated>)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:333)
    at org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration$1$1.initEurekaEnvironment(EurekaServerInitializerConfiguration.java:109)
    at com.netflix.eureka.EurekaBootStrap.contextInitialized(EurekaBootStrap.java:88)
    at org.springframework.cloud.netflix.eureka.server.EurekaServerInitializerConfiguration$1.run(EurekaServerInitializerConfiguration.java:100)
    at java.lang.Thread.run(Thread.java:744)

Affects: 4.0.7

Reference URL: spring-cloud/spring-cloud-netflix#25

Issue Links:

Referenced from: commits 2490d1b, 1ef06cc

Backported to: 4.0.9

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Fixed through internally using a CopyOnWriteArrayList in MutablePropertySources.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants