Skip to content

Commit c2dab9c

Browse files
committed
EmbeddedDatabaseFactory shuts down database when failing to populate it in initDatabase (SPR-7536)
1 parent 609f91e commit c2dab9c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2010 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.
@@ -135,7 +135,14 @@ protected void initDatabase() {
135135

136136
// Now populate the database
137137
if (this.databasePopulator != null) {
138-
populateDatabase();
138+
try {
139+
populateDatabase();
140+
}
141+
catch (RuntimeException ex) {
142+
// failed to populate, so leave it as not initialized
143+
shutdownDatabase();
144+
throw ex;
145+
}
139146
}
140147
}
141148

0 commit comments

Comments
 (0)