Skip to content

Commit

Permalink
Upgrade H2 to 2.1.210
Browse files Browse the repository at this point in the history
Fixes #9354
  • Loading branch information
gsmet committed Mar 31, 2022
1 parent 8eb28bf commit b1277a3
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 53 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<httpasync.version>4.1.5</httpasync.version>
<cronutils.version>9.1.6</cronutils.version>
<quartz.version>2.3.2</quartz.version>
<h2.version>1.4.197</h2.version> <!-- keep 1.4.197 as newer versions have severe regressions -->
<h2.version>2.1.210</h2.version>
<postgresql-jdbc.version>42.3.3</postgresql-jdbc.version>
<mariadb-jdbc.version>3.0.4</mariadb-jdbc.version>
<mysql-jdbc.version>8.0.28</mysql-jdbc.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt
OptionalInt port, LaunchMode launchMode, Optional<Duration> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -49,4 +50,9 @@ void configureAgroalConnection(BuildProducer<AdditionalBeanBuildItem> additional
void registerDefaultDbType(BuildProducer<DefaultDataSourceDbKindBuildItem> dbKind) {
dbKind.produce(new DefaultDataSourceDbKindBuildItem(DatabaseKind.H2));
}

@BuildStep
void runtimeInitializedClasses(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitializedClasses) {
runtimeInitializedClasses.produce(new RuntimeInitializedClassBuildItem("org.h2.store.fs.niomem.FileNioMemData"));
}
}
2 changes: 1 addition & 1 deletion extensions/jdbc/jdbc-h2/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.15.0</version>
<version>1.17.0</version>
<!--
TODO: Make this an optional dependency?
Graal compiler not happy with broken classpaths
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@
public final class Engine {

@Substitute
public static Engine getInstance() {
return new Engine();
}

@Substitute
public Session createSession(ConnectionInfo ci) {
public static Session createSession(ConnectionInfo ci) {
throw new UnsupportedOperationException(
"H2 database compiled into a native-image is only functional as a client: can't create an Embedded Database Session");
}

@Substitute
void close(String name) {
static void close(String name) {
//no-op
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import com.oracle.svm.core.annotate.TargetClass;

/**
* The org.h2.engine.Session represents the "Embedded Database" in H2.
* The org.h2.engine.SessionLocal represents the "Embedded Database" in H2.
* We remove this explicitly as it pulls in various things we can't support;
* rather than address them individually it's simpler to make sure this
* Session doesn't get included by mistake: that will produce errors
* that are easier to manage.
*/
@TargetClass(className = "org.h2.engine.Session")
@TargetClass(className = "org.h2.engine.SessionLocal")
@Delete
public final class SessionDisable {
public final class SessionLocalDisable {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.quarkus.jdbc.h2.runtime.graal;

import org.h2.engine.ConnectionInfo;
import org.h2.engine.Session;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "org.h2.engine.SessionRemote")
public final class SessionRemote {

@Alias
private ConnectionInfo connectionInfo;

/**
* Even if in SessionRemote, this method originally can instantiate a local engine.
* We don't want that as we don't support a local engine.
*/
@Substitute
public Session connectEmbeddedOrServer(boolean openNew) {
ConnectionInfo ci = connectionInfo;
if (ci.isRemote()) {
connectServer(ci);
return (Session) (Object) this;
}

throw new UnsupportedOperationException(
"H2 database compiled into a native-image is only functional as a client: can't create an Embedded Database Session");
}

@Alias
private void connectServer(ConnectionInfo ci) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class H2DatabaseTestResource implements QuarkusTestResourceLifecycleManag
public Map<String, String> start() {

try {
tcpServer = Server.createTcpServer();
tcpServer = Server.createTcpServer("-ifNotExists");
tcpServer.start();
System.out.println("[INFO] H2 database started in TCP server mode; server status: " + tcpServer.getStatus());
} catch (SQLException e) {
Expand Down

0 comments on commit b1277a3

Please sign in to comment.