11/*
2- * Copyright 2002-2015 the original author or authors.
2+ * Copyright 2002-2016 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.
@@ -1498,11 +1498,14 @@ else if (mbd.isLazyInit()) {
14981498 */
14991499 protected void markBeanAsCreated (String beanName ) {
15001500 if (!this .alreadyCreated .contains (beanName )) {
1501- this .alreadyCreated .add (beanName );
1502-
1503- // Let the bean definition get re-merged now that we're actually creating
1504- // the bean... just in case some of its metadata changed in the meantime.
1505- clearMergedBeanDefinition (beanName );
1501+ synchronized (this .mergedBeanDefinitions ) {
1502+ if (!this .alreadyCreated .contains (beanName )) {
1503+ // Let the bean definition get re-merged now that we're actually creating
1504+ // the bean... just in case some of its metadata changed in the meantime.
1505+ clearMergedBeanDefinition (beanName );
1506+ this .alreadyCreated .add (beanName );
1507+ }
1508+ }
15061509 }
15071510 }
15081511
@@ -1511,7 +1514,9 @@ protected void markBeanAsCreated(String beanName) {
15111514 * @param beanName the name of the bean
15121515 */
15131516 protected void cleanupAfterBeanCreationFailure (String beanName ) {
1514- this .alreadyCreated .remove (beanName );
1517+ synchronized (this .mergedBeanDefinitions ) {
1518+ this .alreadyCreated .remove (beanName );
1519+ }
15151520 }
15161521
15171522 /**
0 commit comments