NIFI-10269 This closes #6241. Upgraded H2 from 2.1.210 to 2.1.214

- Adjusted H2DatabaseUpdater to catch generalized SQLNonTransientException instead of H2 JdbcSQLNonTransientException

Signed-off-by: Joe Witt <joewitt@apache.org>
This commit is contained in:
exceptionfactory 2022-07-22 20:20:47 -05:00 committed by Joe Witt
parent 21b57e36e8
commit 077e09cf3e
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
2 changed files with 7 additions and 5 deletions

View File

@ -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;
@ -28,6 +27,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLNonTransientException;
import java.sql.Statement;
public class H2DatabaseUpdater {
@ -48,16 +48,18 @@ public class H2DatabaseUpdater {
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);

View File

@ -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>