Skip to content

Commit

Permalink
NIFI-10269 This closes apache#6241. Upgraded H2 from 2.1.210 to 2.1.214
Browse files Browse the repository at this point in the history
- Adjusted H2DatabaseUpdater to catch generalized SQLNonTransientException instead of H2 JdbcSQLNonTransientException

Signed-off-by: Joe Witt <[email protected]>
  • Loading branch information
exceptionfactory authored and joewitt committed Jul 24, 2022
1 parent 21b57e3 commit 077e09c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.nifi.h2.database.migration;

import org.h2.jdbc.JdbcSQLNonTransientException;
import org.h2.jdbcx.JdbcDataSource;
import org.h2.mvstore.MVStoreException;
import org.slf4j.Logger;
Expand All @@ -28,6 +27,7 @@
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import java.sql.Statement;

public class H2DatabaseUpdater {
Expand All @@ -48,16 +48,18 @@ public static void checkAndPerformMigration(final String dbPathNoExtension, fina
migrationDataSource.setPassword(pass);
try (Connection connection = migrationDataSource.getConnection()) {
return;
} catch (JdbcSQLNonTransientException jsqlnte) {
} catch (SQLNonTransientException e) {
// Migration/version issues will be caused by an MVStoreException
final Throwable exceptionCause = jsqlnte.getCause();
final Throwable exceptionCause = e.getCause();
if (exceptionCause instanceof MVStoreException) {
// Check for specific error message
final String errorMessage = exceptionCause.getMessage();
if (!errorMessage.contains("The write format")
&& !errorMessage.contains("is smaller than the supported format")) {
throw jsqlnte;
throw e;
}
} else {
throw e;
}
} catch (SQLException sqle) {
throw new RuntimeException(String.format("H2 connection failed URL [%s] File [%s]", dbUrl, dbPathNoExtension), sqle);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<netty.4.version>4.1.79.Final</netty.4.version>
<spring.version>5.3.22</spring.version>
<spring.security.version>5.7.2</spring.security.version>
<h2.version>2.1.210</h2.version>
<h2.version>2.1.214</h2.version>
<zookeeper.version>3.8.0</zookeeper.version>
</properties>
<dependencyManagement>
Expand Down

0 comments on commit 077e09c

Please sign in to comment.