From a564ea4c37d66bbb25d54b71e1b730b043b578a3 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 31 Mar 2022 12:07:25 +0200 Subject: [PATCH] Upgrade H2 to 2.1.210 Fixes #9354 --- bom/application/pom.xml | 2 +- .../h2/deployment/H2DevServicesProcessor.java | 3 +- ...ayExtensionCleanAndMigrateAtStartTest.java | 4 +- .../test/FlywayExtensionCleanAtStartTest.java | 4 +- ...FlywayExtensionFilesystemResourceTest.java | 4 +- .../flyway/test/FlywayH2TestCustomizer.java | 2 +- .../model/annotation/user/User.java | 2 + .../model/config/user/User.java | 2 + .../PublicFieldAccessAssociationsTest.java | 2 + .../jdbc/h2/deployment/JDBCH2Processor.java | 6 +++ extensions/jdbc/jdbc-h2/runtime/pom.xml | 2 +- .../jdbc/h2/runtime/graal/CompareMode.java | 39 ------------------- .../quarkus/jdbc/h2/runtime/graal/Engine.java | 9 +---- ...nDisable.java => SessionLocalDisable.java} | 6 +-- .../jdbc/h2/runtime/graal/SessionRemote.java | 35 +++++++++++++++++ ...seExtensionCleanAndMigrateAtStartTest.java | 9 +++-- .../LiquibaseExtensionCleanAtStartTest.java | 8 ++-- .../spring/data/deployment/BasicTypeData.java | 2 + .../quarkus/spring/data/deployment/User.java | 2 + .../src/test/resources/import_users.sql | 2 +- .../main/java/io/quarkus/it/common/Clown.java | 3 +- .../quarkus/it/panache/TestEndpointRunner.kt | 2 +- .../io/quarkus/it/jpa/CustomTypeEntity.java | 2 +- .../main/java/io/quarkus/it/jpa/Person.java | 2 +- .../io/quarkus/it/jpa/SequencedAddress.java | 2 +- .../it/spring/data/jpa/CatalogValue.java | 2 + .../src/main/resources/import.sql | 8 ++-- .../test/h2/H2DatabaseTestResource.java | 2 +- 28 files changed, 92 insertions(+), 76 deletions(-) delete mode 100644 extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/CompareMode.java rename extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/{SessionDisable.java => SessionLocalDisable.java} (70%) create mode 100644 extensions/jdbc/jdbc-h2/runtime/src/main/java/io/quarkus/jdbc/h2/runtime/graal/SessionRemote.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 24a1858222f904..cf1c48df98c964 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -113,7 +113,7 @@ 4.1.5 9.1.6 2.3.2 - 1.4.197 + 2.1.210 42.3.3 3.0.4 8.0.28 diff --git a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java index 1489eccd1af192..9b4fb7a7200aa8 100644 --- a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java +++ b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java @@ -34,7 +34,8 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt OptionalInt port, LaunchMode launchMode, Optional startupTimeout) { try { final Server tcpServer = Server.createTcpServer("-tcpPort", - port.isPresent() ? String.valueOf(port.getAsInt()) : "0"); + port.isPresent() ? String.valueOf(port.getAsInt()) : "0", + "-ifNotExists"); tcpServer.start(); StringBuilder additionalArgs = new StringBuilder(); diff --git a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAndMigrateAtStartTest.java b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAndMigrateAtStartTest.java index 4d3ddf97e0b10f..fd0ca9159bf5bc 100644 --- a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAndMigrateAtStartTest.java +++ b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAndMigrateAtStartTest.java @@ -11,7 +11,7 @@ import javax.inject.Inject; import org.flywaydb.core.Flyway; -import org.h2.jdbc.JdbcSQLException; +import org.h2.jdbc.JdbcSQLSyntaxErrorException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -40,7 +40,7 @@ public void testFlywayConfigInjection() throws SQLException { try (Connection connection = defaultDataSource.getConnection(); Statement stat = connection.createStatement()) { try (ResultSet executeQuery = stat.executeQuery("select * from fake_existing_tbl")) { fail("fake_existing_tbl should not exist"); - } catch (JdbcSQLException e) { + } catch (JdbcSQLSyntaxErrorException e) { // expected fake_existing_tbl does not exist } } diff --git a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAtStartTest.java b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAtStartTest.java index bcb556266849e5..72b9944c89a9f2 100644 --- a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAtStartTest.java +++ b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionCleanAtStartTest.java @@ -12,7 +12,7 @@ import org.flywaydb.core.Flyway; import org.flywaydb.core.api.MigrationInfo; -import org.h2.jdbc.JdbcSQLException; +import org.h2.jdbc.JdbcSQLSyntaxErrorException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -41,7 +41,7 @@ public void testFlywayConfigInjection() throws SQLException { try (Connection connection = defaultDataSource.getConnection(); Statement stat = connection.createStatement()) { try (ResultSet executeQuery = stat.executeQuery("select * from fake_existing_tbl")) { fail("fake_existing_tbl should not exist"); - } catch (JdbcSQLException e) { + } catch (JdbcSQLSyntaxErrorException e) { // expected fake_existing_tbl does not exist } } diff --git a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionFilesystemResourceTest.java b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionFilesystemResourceTest.java index bb1c8c6f0c004b..e81138661eeaaf 100644 --- a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionFilesystemResourceTest.java +++ b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayExtensionFilesystemResourceTest.java @@ -16,7 +16,7 @@ import org.flywaydb.core.api.migration.BaseJavaMigration; import org.flywaydb.core.api.migration.Context; import org.flywaydb.core.api.migration.JavaMigration; -import org.h2.jdbc.JdbcSQLException; +import org.h2.jdbc.JdbcSQLSyntaxErrorException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -45,7 +45,7 @@ public void testFlywayConfigInjection() throws SQLException { try (Connection connection = defaultDataSource.getConnection(); Statement stat = connection.createStatement()) { try (ResultSet executeQuery = stat.executeQuery("select * from fake_existing_tbl")) { fail("fake_existing_tbl should not exist. Clean was run at start"); - } catch (JdbcSQLException e) { + } catch (JdbcSQLSyntaxErrorException e) { // expected fake_existing_tbl does not exist } try (ResultSet countQuery = stat.executeQuery("select count(1) from quarked_flyway")) { diff --git a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayH2TestCustomizer.java b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayH2TestCustomizer.java index 43ffd5c100a243..75ab8a1830b4f9 100644 --- a/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayH2TestCustomizer.java +++ b/extensions/flyway/deployment/src/test/java/io/quarkus/flyway/test/FlywayH2TestCustomizer.java @@ -38,7 +38,7 @@ public FlywayH2TestCustomizer withInitSqlFile(String initSqlFile) { void startH2() { try { - tcpServer = Server.createTcpServer("-tcpPort", String.valueOf(port)); + tcpServer = Server.createTcpServer("-tcpPort", String.valueOf(port), "-ifNotExists"); tcpServer.start(); System.out.println("[INFO] Custom H2 database started in TCP server mode; server status: " + tcpServer.getStatus()); if (initSqlFile != null) { diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/annotation/user/User.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/annotation/user/User.java index 833bc4bc007e20..5071e3a6921509 100644 --- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/annotation/user/User.java +++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/annotation/user/User.java @@ -4,8 +4,10 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Table; @Entity +@Table(name = "User_") public class User { private long id; diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/config/user/User.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/config/user/User.java index bc14b159e90ed3..97689aadcf8018 100644 --- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/config/user/User.java +++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/model/config/user/User.java @@ -4,8 +4,10 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Table; @Entity +@Table(name = "User_") public class User { private long id; diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/publicfields/PublicFieldAccessAssociationsTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/publicfields/PublicFieldAccessAssociationsTest.java index 47899dee9a8fe3..d1501dcf4903cf 100644 --- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/publicfields/PublicFieldAccessAssociationsTest.java +++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/publicfields/PublicFieldAccessAssociationsTest.java @@ -6,6 +6,7 @@ import java.util.List; import javax.inject.Inject; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.GeneratedValue; @@ -157,6 +158,7 @@ public static class ContainedEntity { @GeneratedValue public long id; + @Column(name = "value_") public String value; @OneToOne diff --git a/extensions/jdbc/jdbc-h2/deployment/src/main/java/io/quarkus/jdbc/h2/deployment/JDBCH2Processor.java b/extensions/jdbc/jdbc-h2/deployment/src/main/java/io/quarkus/jdbc/h2/deployment/JDBCH2Processor.java index 6b942aa7198353..1f4d7239cf22f2 100644 --- a/extensions/jdbc/jdbc-h2/deployment/src/main/java/io/quarkus/jdbc/h2/deployment/JDBCH2Processor.java +++ b/extensions/jdbc/jdbc-h2/deployment/src/main/java/io/quarkus/jdbc/h2/deployment/JDBCH2Processor.java @@ -13,6 +13,7 @@ import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.SslNativeConfigBuildItem; +import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.jdbc.h2.runtime.H2AgroalConnectionConfigurer; public class JDBCH2Processor { @@ -49,4 +50,9 @@ void configureAgroalConnection(BuildProducer additional void registerDefaultDbType(BuildProducer dbKind) { dbKind.produce(new DefaultDataSourceDbKindBuildItem(DatabaseKind.H2)); } + + @BuildStep + void runtimeInitializedClasses(BuildProducer runtimeInitializedClasses) { + runtimeInitializedClasses.produce(new RuntimeInitializedClassBuildItem("org.h2.store.fs.niomem.FileNioMemData")); + } } diff --git a/extensions/jdbc/jdbc-h2/runtime/pom.xml b/extensions/jdbc/jdbc-h2/runtime/pom.xml index 2d9da9183b1855..a0681c7c207e3a 100644 --- a/extensions/jdbc/jdbc-h2/runtime/pom.xml +++ b/extensions/jdbc/jdbc-h2/runtime/pom.xml @@ -24,7 +24,7 @@ org.locationtech.jts jts-core - 1.15.0 + 1.17.0