Browse Source

Defensively acquire singleton lock for FactoryBean type check

Closes gh-34247
pull/34398/head
Juergen Hoeller 11 months ago
parent
commit
8771b9ea21
  1. 8
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

8
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -991,7 +991,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -991,7 +991,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
*/
@Nullable
private FactoryBean<?> getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
this.singletonLock.lock();
boolean locked = this.singletonLock.tryLock();
if (!locked) {
return null;
}
try {
BeanWrapper bw = this.factoryBeanInstanceCache.get(beanName);
if (bw != null) {

Loading…
Cancel
Save