[jOOQ/jOOQ#14791] SQLDialect version check throws NumberFormatException

in Percona DB
This commit is contained in:
Lukas Eder 2023-03-15 10:36:25 +01:00
parent 701fb31f8b
commit db0396033f
2 changed files with 8 additions and 2 deletions

View File

@ -43,6 +43,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
import java.util.concurrent.locks.Condition;
import java.util.regex.Pattern;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -1375,6 +1377,8 @@ public enum SQLDialect {
);
}
private static final Pattern P_PATCH_VERSION_MYSQL = Pattern.compile("^\\d+\\.\\d+\\.(\\d+).*$");
private final int patchVersion(String productVersion) {
if (productVersion == null)
return Integer.MAX_VALUE;
@ -1383,7 +1387,7 @@ public enum SQLDialect {
case H2:
return Integer.parseInt(productVersion.split(" ")[0].split("\\.")[2]);
case MYSQL:
return Integer.parseInt(productVersion.split("\\.")[2]);
return Integer.parseInt(P_PATCH_VERSION_MYSQL.matcher(productVersion).replaceFirst("$1"));
default:
return Integer.MAX_VALUE;
}

View File

@ -644,7 +644,9 @@ class DefaultExecuteContext implements ExecuteContext {
else
logVersionSupport.info("Version", "Database version is supported by dialect " + dialect() + ": " + productVersion);
}
catch (SQLException e) {
// [#14791] Could also be NumberFormatException when reading non-standard version numbers
catch (Exception e) {
logVersionSupport.error("Error reading database version", e);
}
}