mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-24 10:38:57 +00:00
#621 - EbeanServer.shutdown(true, false) followed by EbeanServerFactory create() when using the same ServerConfig give SQLException: Trying to access the Connection Pool when it is shutting down
This commit is contained in:
@@ -398,9 +398,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
*/
|
||||
private void shutdownInternal(boolean shutdownDataSource, boolean deregisterDriver) {
|
||||
|
||||
logger.debug("Shutting down EbeanServer " + getName());
|
||||
logger.debug("Shutting down EbeanServer {}", serverName);
|
||||
if (shutdown) {
|
||||
// Already shutdown
|
||||
// already shutdown
|
||||
return;
|
||||
}
|
||||
shutdownPlugins();
|
||||
@@ -411,6 +411,10 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
// shutdown DataSource (if its an Ebean one)
|
||||
transactionManager.shutdown(shutdownDataSource, deregisterDriver);
|
||||
shutdown = true;
|
||||
if (shutdownDataSource) {
|
||||
// deregister the DataSource in case ServerConfig is re-used
|
||||
serverConfig.setDataSource(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void shutdownPlugins() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class EbeanServerFactory_ServerConfigStart_Test {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
public void test() throws InterruptedException {
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
config.setName("h2");
|
||||
@@ -34,6 +34,12 @@ public class EbeanServerFactory_ServerConfigStart_Test {
|
||||
assertThat(OnStartupViaClass.calledWithConfig).isSameAs(config);
|
||||
|
||||
assertThat(ebeanServer).isNotNull();
|
||||
|
||||
// test server shutdown and restart using the same ServerConfig
|
||||
ebeanServer.shutdown(true, false);
|
||||
|
||||
EbeanServer restartedServer = EbeanServerFactory.create(config);
|
||||
restartedServer.shutdown(true, false);
|
||||
}
|
||||
|
||||
public static class OnStartup implements ServerConfigStartup {
|
||||
|
||||
Reference in New Issue
Block a user