Skip to content

Commit 8771b9e

Browse files
committed
Defensively acquire singleton lock for FactoryBean type check
Closes gh-34247
1 parent ff72652 commit 8771b9e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -991,7 +991,11 @@ protected Object getEarlyBeanReference(String beanName, RootBeanDefinition mbd,
991991
*/
992992
@Nullable
993993
private FactoryBean<?> getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
994-
this.singletonLock.lock();
994+
boolean locked = this.singletonLock.tryLock();
995+
if (!locked) {
996+
return null;
997+
}
998+
995999
try {
9961000
BeanWrapper bw = this.factoryBeanInstanceCache.get(beanName);
9971001
if (bw != null) {

0 commit comments

Comments
 (0)