title: Spring Boot 2.3 with JPA: CommandLineRunner finish delayed
body: <p>I have a CommandLineRunner on Spring Boot 2.3.3 using JPA which has a 1 minute delay after finishing (see log below). This happens even when there are no entity classes present and there is no JPA operation. It's reproducible with a project consisting of only a mainly empty main class.</p>
  <p>This did not occur with version 2.2.7, but does on 2.3.1. It happens not only on h2 but also on other databases (derby, oracle). If I use only spring-boot-starter-data-jdbc instead of spring-boot-starter-data-jpa there is no delay.</p>
  <p>Is there any way to avoid this delay?</p>
  <pre><code>2020-09-01 10:51:57.408  INFO 30314 --- [           main] testcase.SlowShutdown                    : Starting SlowShutdown on io with PID 30314 
  2020-09-01 10:51:57.410  INFO 30314 --- [           main] testcase.SlowShutdown                    : No active profile set, falling back to default profiles: default
  2020-09-01 10:51:57.858  INFO 30314 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
  2020-09-01 10:51:57.873  INFO 30314 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 10ms. Found 0 JPA repository interfaces.
  2020-09-01 10:51:58.095  INFO 30314 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
  2020-09-01 10:51:58.100  INFO 30314 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
  2020-09-01 10:51:58.171  INFO 30314 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
  2020-09-01 10:51:58.216  INFO 30314 --- [         task-1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
  2020-09-01 10:51:58.243  INFO 30314 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.20.Final
  2020-09-01 10:51:58.274  INFO 30314 --- [           main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
  2020-09-01 10:51:58.274  INFO 30314 --- [           main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
  2020-09-01 10:51:58.282  INFO 30314 --- [           main] testcase.SlowShutdown                    : Started SlowShutdown in 1.118 seconds (JVM running for 1.579)
  2020-09-01 10:51:58.283  INFO 30314 --- [           main] testcase.SlowShutdown                    : start
  2020-09-01 10:51:58.315  INFO 30314 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
  2020-09-01 10:51:58.387  INFO 30314 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
  2020-09-01 10:51:58.498  INFO 30314 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
  2020-09-01 10:51:58.502  INFO 30314 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
  2020-09-01 10:52:58.512  INFO 30314 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
  2020-09-01 10:52:58.513  INFO 30314 --- [extShutdownHook] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
  2020-09-01 10:52:58.519  INFO 30314 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
  2020-09-01 10:52:58.521  INFO 30314 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
  2020-09-01 10:52:58.529  INFO 30314 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
  </code></pre>
  <p>Pom:</p>
  <pre><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.3.3.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt;
    &lt;/parent&gt;
    &lt;groupId&gt;test&lt;/groupId&gt;
    &lt;artifactId&gt;slowshutdown&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;slowshutdown&lt;/name&gt;
    &lt;description&gt;slowshutdown&lt;/description&gt;
    &lt;properties&gt;
      &lt;java.version&gt;11&lt;/java.version&gt;
    &lt;/properties&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.h2database&lt;/groupId&gt;
        &lt;artifactId&gt;h2&lt;/artifactId&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  <p>Main class:</p>
  <pre><code>package testcase;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.springframework.boot.CommandLineRunner;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  
  @SpringBootApplication
  public class SlowShutdown implements CommandLineRunner {
    private static final Log log = LogFactory.getLog(SlowShutdown.class);
  
    public static void main(String[] args) {
      SpringApplication.run(SlowShutdown.class, args);
    }
  
    @Override
    public void run(String... args) throws Exception {
      log.info(&quot;start&quot;);
    }
  }
  </code></pre>