Skip to content

Commit

Permalink
Defensively acquire singleton lock for FactoryBean type check
Browse files Browse the repository at this point in the history
Closes gh-34247
  • Loading branch information
jhoeller committed Jan 13, 2025
1 parent ff72652 commit 8771b9e
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -991,7 +991,11 @@ protected Object getEarlyBeanReference(String beanName, RootBeanDefinition mbd,
*/
@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) {
Expand Down

0 comments on commit 8771b9e

Please sign in to comment.