Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undesired URL encoding of connection property #1222

Open
basdebakker opened this issue Dec 13, 2024 · 1 comment
Open

Undesired URL encoding of connection property #1222

basdebakker opened this issue Dec 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@basdebakker
Copy link

Describe the bug

When connecting through the wrapper, connection property values specified in the URL are encoded in the new URL used for the wrapped JDBC driver. This leads to an unusable value and a connection error.

Expected Behavior

No exception.

What plugins are used? What other connection properties were set?

No plugins were used.

Current Behavior

Exception in thread "main" java.sql.SQLNonTransientConnectionException: (conn=38) Initialization command fail
	at org.mariadb.jdbc.export.ExceptionFactory.createException(ExceptionFactory.java:300)
	at org.mariadb.jdbc.export.ExceptionFactory.create(ExceptionFactory.java:366)
	at org.mariadb.jdbc.client.impl.StandardClient.postConnectionQueries(StandardClient.java:719)
	at org.mariadb.jdbc.client.impl.StandardClient.<init>(StandardClient.java:241)
	at org.mariadb.jdbc.Driver.connect(Driver.java:73)
	at org.mariadb.jdbc.MariaDbDataSource.getConnection(MariaDbDataSource.java:80)
	at software.amazon.jdbc.DataSourceConnectionProvider.openConnection(DataSourceConnectionProvider.java:172)
	at software.amazon.jdbc.DataSourceConnectionProvider.connect(DataSourceConnectionProvider.java:145)
	at software.amazon.jdbc.plugin.DefaultConnectionPlugin.connectInternal(DefaultConnectionPlugin.java:208)
	at software.amazon.jdbc.plugin.DefaultConnectionPlugin.connect(DefaultConnectionPlugin.java:191)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$connect$6(ConnectionPluginManager.java:378)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$null$0(ConnectionPluginManager.java:268)
	at software.amazon.jdbc.ConnectionPluginManager.executeWithTelemetry(ConnectionPluginManager.java:245)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$makePluginChainFunc$1(ConnectionPluginManager.java:268)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$null$2(ConnectionPluginManager.java:273)
	at software.amazon.jdbc.plugin.efm2.HostMonitoringConnectionPlugin.connectInternal(HostMonitoringConnectionPlugin.java:234)
	at software.amazon.jdbc.plugin.efm2.HostMonitoringConnectionPlugin.connect(HostMonitoringConnectionPlugin.java:229)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$connect$6(ConnectionPluginManager.java:378)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$null$3(ConnectionPluginManager.java:272)
	at software.amazon.jdbc.ConnectionPluginManager.executeWithTelemetry(ConnectionPluginManager.java:245)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$makePluginChainFunc$4(ConnectionPluginManager.java:272)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$null$2(ConnectionPluginManager.java:273)
	at software.amazon.jdbc.plugin.staledns.AuroraStaleDnsHelper.getVerifiedConnection(AuroraStaleDnsHelper.java:69)
	at software.amazon.jdbc.plugin.failover.FailoverConnectionPlugin.connectInternal(FailoverConnectionPlugin.java:823)
	at software.amazon.jdbc.plugin.failover.FailoverConnectionPlugin.connect(FailoverConnectionPlugin.java:813)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$connect$6(ConnectionPluginManager.java:378)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$null$3(ConnectionPluginManager.java:272)
	at software.amazon.jdbc.ConnectionPluginManager.executeWithTelemetry(ConnectionPluginManager.java:245)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$makePluginChainFunc$4(ConnectionPluginManager.java:272)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$null$2(ConnectionPluginManager.java:273)
	at software.amazon.jdbc.plugin.AuroraConnectionTrackerPlugin.connectInternal(AuroraConnectionTrackerPlugin.java:93)
	at software.amazon.jdbc.plugin.AuroraConnectionTrackerPlugin.connect(AuroraConnectionTrackerPlugin.java:86)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$connect$6(ConnectionPluginManager.java:378)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$null$3(ConnectionPluginManager.java:272)
	at software.amazon.jdbc.ConnectionPluginManager.executeWithTelemetry(ConnectionPluginManager.java:245)
	at software.amazon.jdbc.ConnectionPluginManager.lambda$makePluginChainFunc$4(ConnectionPluginManager.java:272)
	at software.amazon.jdbc.ConnectionPluginManager.executeWithSubscribedPlugins(ConnectionPluginManager.java:235)
	at software.amazon.jdbc.ConnectionPluginManager.connect(ConnectionPluginManager.java:375)
	at software.amazon.jdbc.wrapper.ConnectionWrapper.init(ConnectionWrapper.java:161)
	at software.amazon.jdbc.wrapper.ConnectionWrapper.<init>(ConnectionWrapper.java:105)
	at software.amazon.jdbc.ds.AwsWrapperDataSource.createConnectionWrapper(AwsWrapperDataSource.java:255)
	at software.amazon.jdbc.ds.AwsWrapperDataSource.getConnection(AwsWrapperDataSource.java:210)
	at software.amazon.jdbc.ds.AwsWrapperDataSource.getConnection(AwsWrapperDataSource.java:95)
	at com.mendix.test.AWSWrapperTest.main(AWSWrapperTest.java:13)
Caused by: java.sql.BatchUpdateException: (conn=38) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '%3DPIPES_AS_CONCAT' at line 1
	at org.mariadb.jdbc.export.ExceptionFactory.createBatchUpdate(ExceptionFactory.java:221)
	at org.mariadb.jdbc.client.impl.StandardClient.executePipeline(StandardClient.java:1011)
	at org.mariadb.jdbc.client.impl.StandardClient.postConnectionQueries(StandardClient.java:680)
	... 41 more
Caused by: java.sql.SQLSyntaxErrorException: (conn=38) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '%3DPIPES_AS_CONCAT' at line 1
	at org.mariadb.jdbc.export.ExceptionFactory.createException(ExceptionFactory.java:289)
	at org.mariadb.jdbc.export.ExceptionFactory.create(ExceptionFactory.java:378)
	at org.mariadb.jdbc.message.ClientMessage.readPacket(ClientMessage.java:189)
	at org.mariadb.jdbc.client.impl.StandardClient.readPacket(StandardClient.java:1246)
	at org.mariadb.jdbc.client.impl.StandardClient.readResults(StandardClient.java:1185)
	at org.mariadb.jdbc.client.impl.StandardClient.readResponse(StandardClient.java:1104)
	at org.mariadb.jdbc.client.impl.StandardClient.executePipeline(StandardClient.java:944)
	... 42 more

Reproduction Steps

Run this code using your own host/port/database/user/password. I'm using mariadb-java-client 3.5.1 and MariaDB server 11.4. When using the MariaDbDataSource directly (without the aws-wrapper in the jdbc URL) there is no exception.

import org.mariadb.jdbc.MariaDbDataSource;
import software.amazon.jdbc.ds.AwsWrapperDataSource;

class AWSWrapperTest {
  public static void main(String[] args) throws Exception {
    AwsWrapperDataSource dataSource = new AwsWrapperDataSource();
    dataSource.setTargetDataSourceClassName(MariaDbDataSource.class.getName());
    dataSource.setJdbcUrl("jdbc:aws-wrapper:mariadb://localhost:44620/DB?sessionVariables=sql_mode=PIPES_AS_CONCAT");
    dataSource.setUser("user");
    dataSource.setPassword("secret");
    dataSource.getConnection();
  }
}

Possible Solution

Properties that are read from the original JDBC URL should not be URL encoded when creating the final JDBC URL, but used as they were written originally.

Additional Information/Context

No response

The AWS Advanced JDBC Driver version used

2.5.3

JDK version used

openjdk version "21.0.2" 2024-01-16 LTS OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode, sharing)

Operating System and version

Windows 11 Enterprise 22H2

@basdebakker basdebakker added the bug Something isn't working label Dec 13, 2024
@aaron-congo
Copy link
Contributor

Hi @basdebakker, thank you for reporting this issue. We'll take a look and update you as we investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants