Skip to content

Commit cd15cbd

Browse files
committed
Do not execute datasource initialization in a separate thread
This commit makes sure that `data.sql` is performed in the same thread as the one initializing the JPA container. Closes gh-22852
1 parent 789fafa commit cd15cbd

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
3636
import org.springframework.context.ApplicationContext;
3737
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
38-
import org.springframework.core.task.AsyncTaskExecutor;
3938
import org.springframework.core.type.AnnotationMetadata;
4039
import org.springframework.orm.jpa.JpaDialect;
4140
import org.springframework.orm.jpa.JpaVendorAdapter;
@@ -194,11 +193,7 @@ public Class<? extends EntityManager> getEntityManagerInterface() {
194193
@Override
195194
public void postProcessEntityManagerFactory(EntityManagerFactory entityManagerFactory) {
196195
this.delegate.postProcessEntityManagerFactory(entityManagerFactory);
197-
AsyncTaskExecutor bootstrapExecutor = this.factoryBean.getBootstrapExecutor();
198-
if (bootstrapExecutor != null) {
199-
bootstrapExecutor.execute(() -> DataSourceInitializedPublisher.this
200-
.publishEventIfRequired(this.factoryBean, entityManagerFactory));
201-
}
196+
publishEventIfRequired(this.factoryBean, entityManagerFactory);
202197
}
203198

204199
}

0 commit comments

Comments
 (0)