From c21e1f879c3bdd4ced2c6c7f4ff289d975cc913b Mon Sep 17 00:00:00 2001 From: Falko Modler Date: Fri, 25 Mar 2022 22:28:21 +0100 Subject: [PATCH] Upgrade mariadb-java-client from 2.7.5 to 3.0.4 --- bom/application/pom.xml | 2 +- .../deployment/JDBCMariaDBProcessor.java | 31 ++++++++--- .../deployment/MariaDBJDBCReflections.java | 17 ++---- ...henticationPluginLoader_Substitutions.java | 52 ------------------- ...va => ConnectionHelper_socketHandler.java} | 6 +-- .../runtime/graal/Pool_disable_JMX.java | 4 +- .../graal/SendPamAuthPacket_Removal.java | 9 ---- .../SendPamAuthPacket_Substitutions.java | 28 ++++++++++ .../graal/SharedMemorySocket_Removal.java | 10 ---- .../graal/SimpleSocketHandlerFunction.java | 18 +++---- .../graal/SocketUtility_Substitutions.java | 4 +- 11 files changed, 72 insertions(+), 109 deletions(-) delete mode 100644 extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/AuthenticationPluginLoader_Substitutions.java rename extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/{Utils_socketHandler.java => ConnectionHelper_socketHandler.java} (66%) delete mode 100644 extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SendPamAuthPacket_Removal.java create mode 100644 extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SendPamAuthPacket_Substitutions.java delete mode 100644 extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SharedMemorySocket_Removal.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 8bf0b029f97e6..dcb41d63845d9 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -115,7 +115,7 @@ 2.3.2 1.4.197 42.3.3 - 2.7.5 + 3.0.4 8.0.28 7.2.2.jre8 1.6.7 diff --git a/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java b/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java index 301e106f5afb2..3f8e709f193ec 100644 --- a/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java +++ b/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/JDBCMariaDBProcessor.java @@ -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; @@ -25,10 +26,11 @@ FeatureBuildItem feature() { } @BuildStep - void registerDriver(BuildProducer jdbcDriver, - SslNativeConfigBuildItem sslNativeConfigBuildItem) { - jdbcDriver.produce(new JdbcDriverBuildItem(DatabaseKind.MARIADB, "org.mariadb.jdbc.Driver", - "org.mariadb.jdbc.MySQLDataSource")); + void registerDriver(BuildProducer jdbcDriver, BuildProducer dbKind) { + jdbcDriver.produce( + new JdbcDriverBuildItem(DatabaseKind.MARIADB, "org.mariadb.jdbc.Driver", "org.mariadb.jdbc.MariaDbDataSource")); + + dbKind.produce(new DefaultDataSourceDbKindBuildItem(DatabaseKind.MARIADB)); } @BuildStep @@ -47,15 +49,28 @@ void configureAgroalConnection(BuildProducer additional } } + @BuildStep + void registerAuthenticationPlugins(BuildProducer serviceProvider) { + // make sure that all plugins are available + serviceProvider + .produce(ServiceProviderBuildItem.allProvidersFromClassPath("org.mariadb.jdbc.plugin.AuthenticationPlugin")); + } + + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) + void addNativeImageResources(BuildProducer 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 serviceProvider, - BuildProducer dbKind) { + BuildProducer 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)); } } diff --git a/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/MariaDBJDBCReflections.java b/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/MariaDBJDBCReflections.java index fe6934edd6c24..f4aeb8dfe5095 100644 --- a/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/MariaDBJDBCReflections.java +++ b/extensions/jdbc/jdbc-mariadb/deployment/src/main/java/io/quarkus/jdbc/mariadb/deployment/MariaDBJDBCReflections.java @@ -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 { @@ -12,18 +11,10 @@ void build(BuildProducer 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 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")); } } diff --git a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/AuthenticationPluginLoader_Substitutions.java b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/AuthenticationPluginLoader_Substitutions.java deleted file mode 100644 index 8e701ccf2020a..0000000000000 --- a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/AuthenticationPluginLoader_Substitutions.java +++ /dev/null @@ -1,52 +0,0 @@ -package io.quarkus.jdbc.mariadb.runtime.graal; - -import java.sql.SQLException; - -import org.mariadb.jdbc.authentication.AuthenticationPlugin; -import org.mariadb.jdbc.authentication.AuthenticationPluginLoader; -import org.mariadb.jdbc.internal.com.send.authentication.ClearPasswordPlugin; -import org.mariadb.jdbc.internal.com.send.authentication.Ed25519PasswordPlugin; -import org.mariadb.jdbc.internal.com.send.authentication.NativePasswordPlugin; -import org.mariadb.jdbc.internal.com.send.authentication.OldPasswordPlugin; -import org.mariadb.jdbc.internal.com.send.authentication.SendGssApiAuthPacket; - -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -@TargetClass(AuthenticationPluginLoader.class) -@Substitute -public final class AuthenticationPluginLoader_Substitutions { - - public static final String MYSQL_NATIVE_PASSWORD = "mysql_native_password"; - public static final String MYSQL_OLD_PASSWORD = "mysql_old_password"; - public static final String MYSQL_CLEAR_PASSWORD = "mysql_clear_password"; - public static final String MYSQL_ED25519_PASSWORD = "client_ed25519"; - private static final String GSSAPI_CLIENT = "auth_gssapi_client"; - private static final String DIALOG = "dialog"; - - @Substitute - public static AuthenticationPlugin get(String type) throws SQLException { - switch (type) { - case MYSQL_NATIVE_PASSWORD: - return new NativePasswordPlugin(); - case MYSQL_OLD_PASSWORD: - return new OldPasswordPlugin(); - case MYSQL_CLEAR_PASSWORD: - return new ClearPasswordPlugin(); - case DIALOG: - throw new UnsupportedOperationException("Authentication strategy 'dialog' is not supported in GraalVM"); - //return new SendPamAuthPacket(); - case GSSAPI_CLIENT: - return new SendGssApiAuthPacket(); - case MYSQL_ED25519_PASSWORD: - return new Ed25519PasswordPlugin(); - - default: - throw new SQLException( - "Client does not support authentication protocol requested by server. " - + "Consider upgrading MariaDB client. plugin was = " + type, - "08004", 1251); - } - } - -} diff --git a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/Utils_socketHandler.java b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/ConnectionHelper_socketHandler.java similarity index 66% rename from extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/Utils_socketHandler.java rename to extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/ConnectionHelper_socketHandler.java index b368bb37ab012..a3a80a3c1dca6 100644 --- a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/Utils_socketHandler.java +++ b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/ConnectionHelper_socketHandler.java @@ -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) diff --git a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/Pool_disable_JMX.java b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/Pool_disable_JMX.java index f7634281cdd84..7c15d21192fc3 100644 --- a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/Pool_disable_JMX.java +++ b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/Pool_disable_JMX.java @@ -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 diff --git a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SendPamAuthPacket_Removal.java b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SendPamAuthPacket_Removal.java deleted file mode 100644 index 06ec3829f6fac..0000000000000 --- a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SendPamAuthPacket_Removal.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.quarkus.jdbc.mariadb.runtime.graal; - -import com.oracle.svm.core.annotate.Delete; -import com.oracle.svm.core.annotate.TargetClass; - -@TargetClass(className = "org.mariadb.jdbc.internal.com.send.authentication.SendPamAuthPacket") -@Delete -public final class SendPamAuthPacket_Removal { -} diff --git a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SendPamAuthPacket_Substitutions.java b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SendPamAuthPacket_Substitutions.java new file mode 100644 index 0000000000000..3fbba0591916c --- /dev/null +++ b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SendPamAuthPacket_Substitutions.java @@ -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"); + } +} diff --git a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SharedMemorySocket_Removal.java b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SharedMemorySocket_Removal.java deleted file mode 100644 index e03e88ff79b8c..0000000000000 --- a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SharedMemorySocket_Removal.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.quarkus.jdbc.mariadb.runtime.graal; - -import com.oracle.svm.core.annotate.Delete; -import com.oracle.svm.core.annotate.TargetClass; - -@TargetClass(className = "org.mariadb.jdbc.internal.io.socket.SharedMemorySocket") -@Delete -public final class SharedMemorySocket_Removal { - -} diff --git a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SimpleSocketHandlerFunction.java b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SimpleSocketHandlerFunction.java index 02c0136984a2a..9e97bb0afb8f0 100644 --- a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SimpleSocketHandlerFunction.java +++ b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SimpleSocketHandlerFunction.java @@ -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) { diff --git a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SocketUtility_Substitutions.java b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SocketUtility_Substitutions.java index 5daa3a585039f..aafaa8bb7e363 100644 --- a/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SocketUtility_Substitutions.java +++ b/extensions/jdbc/jdbc-mariadb/runtime/src/main/java/io/quarkus/jdbc/mariadb/runtime/graal/SocketUtility_Substitutions.java @@ -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