Skip to content

Commit de2af00

Browse files
committed
Catch and throw MigrationException
1 parent 7286d8f commit de2af00

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

ebean-migration/src/main/java/io/ebean/migration/runner/MigrationEngine.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public List<MigrationResource> run(Connection connection) {
5656
}
5757
}
5858
return result;
59+
} catch (MigrationException e) {
60+
rollback(connection);
61+
throw e;
5962
} catch (Exception e) {
6063
log.log(ERROR, "Perform rollback due to DB migration error", e);
6164
rollback(connection);
@@ -143,7 +146,7 @@ private void close(Connection connection) {
143146
/**
144147
* Rollback the connection logging if an error occurs.
145148
*/
146-
private void rollback(Connection connection) {
149+
static void rollback(Connection connection) {
147150
try {
148151
if (connection != null) {
149152
connection.rollback();

ebean-migration/src/main/java/io/ebean/migration/runner/MigrationPlatform.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/**
1313
* Handle database platform specific locking on db migration table.
1414
*/
15+
@SuppressWarnings({"SqlDialectInspection", "SqlSourceToSinkFlow"})
1516
class MigrationPlatform {
1617

1718
private static final System.Logger log = MigrationTable.log;
@@ -124,7 +125,7 @@ void unlockMigrationTable(String sqlTable, Connection connection) {
124125
releaseLogicalLock(sqlTable, connection);
125126
connection.commit();
126127
} catch (SQLException e) {
127-
rollback(connection);
128+
MigrationEngine.rollback(connection);
128129
throw new MigrationException("Error releasing logical lock for ebean migrations");
129130
}
130131
}
@@ -196,7 +197,6 @@ private boolean obtainNamedLock(Connection connection) throws SQLException {
196197
return false;
197198
}
198199

199-
@SuppressWarnings("all")
200200
@Override
201201
void unlockMigrationTable(String sqlTable, Connection connection) {
202202
try {

0 commit comments

Comments
 (0)