Skip to content

Commit

Permalink
Merge pull request #24570 from famod/mariadb-client-3.0.4
Browse files Browse the repository at this point in the history
Upgrade mariadb-java-client from 2.7.5 to 3.0.4
  • Loading branch information
gsmet authored Mar 26, 2022
2 parents 39072dd + c21e1f8 commit b051eb9
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 109 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<quartz.version>2.3.2</quartz.version>
<h2.version>1.4.197</h2.version> <!-- keep 1.4.197 as newer versions have severe regressions -->
<postgresql-jdbc.version>42.3.3</postgresql-jdbc.version>
<mariadb-jdbc.version>2.7.5</mariadb-jdbc.version>
<mariadb-jdbc.version>3.0.4</mariadb-jdbc.version>
<mysql-jdbc.version>8.0.28</mysql-jdbc.version>
<mssql-jdbc.version>7.2.2.jre8</mssql-jdbc.version>
<adal4j.version>1.6.7</adal4j.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.SslNativeConfigBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
import io.quarkus.jdbc.mariadb.runtime.MariaDBAgroalConnectionConfigurer;
import io.quarkus.jdbc.mariadb.runtime.MariaDBServiceBindingConverter;

Expand All @@ -25,10 +26,11 @@ FeatureBuildItem feature() {
}

@BuildStep
void registerDriver(BuildProducer<JdbcDriverBuildItem> jdbcDriver,
SslNativeConfigBuildItem sslNativeConfigBuildItem) {
jdbcDriver.produce(new JdbcDriverBuildItem(DatabaseKind.MARIADB, "org.mariadb.jdbc.Driver",
"org.mariadb.jdbc.MySQLDataSource"));
void registerDriver(BuildProducer<JdbcDriverBuildItem> jdbcDriver, BuildProducer<DefaultDataSourceDbKindBuildItem> dbKind) {
jdbcDriver.produce(
new JdbcDriverBuildItem(DatabaseKind.MARIADB, "org.mariadb.jdbc.Driver", "org.mariadb.jdbc.MariaDbDataSource"));

dbKind.produce(new DefaultDataSourceDbKindBuildItem(DatabaseKind.MARIADB));
}

@BuildStep
Expand All @@ -47,15 +49,28 @@ void configureAgroalConnection(BuildProducer<AdditionalBeanBuildItem> additional
}
}

@BuildStep
void registerAuthenticationPlugins(BuildProducer<ServiceProviderBuildItem> serviceProvider) {
// make sure that all plugins are available
serviceProvider
.produce(ServiceProviderBuildItem.allProvidersFromClassPath("org.mariadb.jdbc.plugin.AuthenticationPlugin"));
}

@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
void addNativeImageResources(BuildProducer<NativeImageResourceBuildItem> resources) {
// mariadb.properties is used by org.mariadb.jdbc.util.VersionFactory and is small enough.
// driver.properties is not added because it only provides optional descriptions for
// org.mariadb.jdbc.Driver.getPropertyInfo(), which is probably not even called.
resources.produce(new NativeImageResourceBuildItem("mariadb.properties"));
}

@BuildStep
void registerServiceBinding(Capabilities capabilities,
BuildProducer<ServiceProviderBuildItem> serviceProvider,
BuildProducer<DefaultDataSourceDbKindBuildItem> dbKind) {
BuildProducer<ServiceProviderBuildItem> serviceProvider) {
if (capabilities.isPresent(Capability.KUBERNETES_SERVICE_BINDING)) {
serviceProvider.produce(
new ServiceProviderBuildItem("io.quarkus.kubernetes.service.binding.runtime.ServiceBindingConverter",
MariaDBServiceBindingConverter.class.getName()));
}
dbKind.produce(new DefaultDataSourceDbKindBuildItem(DatabaseKind.MARIADB));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;

public final class MariaDBJDBCReflections {

Expand All @@ -12,18 +11,10 @@ void build(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
//Not strictly necessary when using Agroal, as it also registers
//any JDBC driver being configured explicitly through its configuration.
//We register it for the sake of people not using Agroal.
final String driverName = "org.mariadb.jdbc.Driver";
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, driverName));
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, "org.mariadb.jdbc.Driver"));

//MariaDB's connection process requires reflective read to all fields of Options:
reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "org.mariadb.jdbc.util.Options"));
}

@BuildStep
void runtimeInit(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitialized) {
//MastersSlavesListener starts threads in DynamicSizedSchedulerImpl which is disallowed during build time in GraalVM
runtimeInitialized
.produce(new RuntimeInitializedClassBuildItem(
"org.mariadb.jdbc.internal.failover.impl.MastersReplicasListener"));
//MariaDB's connection process requires reflective read to all fields of Configuration and its Builder:
reflectiveClass.produce(new ReflectiveClassBuildItem(false, true,
"org.mariadb.jdbc.Configuration", "org.mariadb.jdbc.Configuration$Builder"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.quarkus.jdbc.mariadb.runtime.graal;

import org.mariadb.jdbc.internal.io.socket.SocketHandlerFunction;
import org.mariadb.jdbc.client.socket.impl.SocketHandlerFunction;

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

@TargetClass(org.mariadb.jdbc.internal.util.Utils.class)
public final class Utils_socketHandler {
@TargetClass(className = "org.mariadb.jdbc.client.impl.ConnectionHelper")
public final class ConnectionHelper_socketHandler {

@Alias
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.quarkus.jdbc.mariadb.runtime.graal;

import org.mariadb.jdbc.internal.logging.Logger;
import org.mariadb.jdbc.util.log.Logger;

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

@TargetClass(org.mariadb.jdbc.internal.util.pool.Pool.class)
@TargetClass(org.mariadb.jdbc.pool.Pool.class)
public final class Pool_disable_JMX {

@Alias
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.jdbc.mariadb.runtime.graal;

import java.io.IOException;
import java.sql.SQLException;

import org.mariadb.jdbc.Configuration;
import org.mariadb.jdbc.client.Context;
import org.mariadb.jdbc.client.ReadableByteBuf;
import org.mariadb.jdbc.client.socket.Reader;
import org.mariadb.jdbc.client.socket.Writer;

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

@TargetClass(className = "org.mariadb.jdbc.plugin.authentication.standard.SendPamAuthPacket")
public final class SendPamAuthPacket_Substitutions {

@Substitute
public void initialize(String authenticationData, byte[] seed, Configuration conf) {
throw new UnsupportedOperationException("Authentication strategy 'dialog' is not supported in GraalVM");
}

@Substitute
public ReadableByteBuf process(Writer out, Reader in, Context context)
throws SQLException, IOException {
throw new UnsupportedOperationException("Authentication strategy 'dialog' is not supported in GraalVM");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

import java.io.IOException;
import java.net.Socket;
import java.sql.SQLException;

import org.mariadb.jdbc.internal.io.socket.SocketHandlerFunction;
import org.mariadb.jdbc.internal.util.Utils;
import org.mariadb.jdbc.util.Options;
import org.mariadb.jdbc.Configuration;
import org.mariadb.jdbc.HostAddress;
import org.mariadb.jdbc.client.impl.ConnectionHelper;
import org.mariadb.jdbc.client.socket.impl.SocketHandlerFunction;

public class SimpleSocketHandlerFunction implements SocketHandlerFunction {
@Override
public Socket apply(Options options, String host) throws IOException {
if (options.pipe != null) {
public Socket apply(Configuration conf, HostAddress hostAddress) throws IOException, SQLException {
if (conf.pipe() != null) {
throw new IllegalArgumentException(getErrorMessage("pipe"));
} else if (options.localSocket != null) {
} else if (conf.localSocket() != null) {
throw new IllegalArgumentException(getErrorMessage("localSocket"));
} else if (options.sharedMemory != null) {
throw new IllegalArgumentException(getErrorMessage("sharedMemory"));
}

return Utils.standardSocket(options, host);
return ConnectionHelper.standardSocket(conf, hostAddress);
}

private String getErrorMessage(String option) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.quarkus.jdbc.mariadb.runtime.graal;

import org.mariadb.jdbc.internal.io.socket.SocketHandlerFunction;
import org.mariadb.jdbc.client.socket.impl.SocketHandlerFunction;

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

@TargetClass(org.mariadb.jdbc.internal.io.socket.SocketUtility.class)
@TargetClass(org.mariadb.jdbc.client.socket.impl.SocketUtility.class)
public final class SocketUtility_Substitutions {

// Ensure that JNA is never used
Expand Down

0 comments on commit b051eb9

Please sign in to comment.