Skip to content

Commit

Permalink
Fix for Bug#101596 (32151143), GET THE 'HOST' PROPERTY ERROR AFTER
Browse files Browse the repository at this point in the history
CALLING TRANSFORMPROPERTIES() METHOD.
  • Loading branch information
soklakov committed Feb 17, 2021
1 parent 9269388 commit 52479cc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

Version 8.0.24

- Fix for Bug#101596 (32151143), GET THE 'HOST' PROPERTY ERROR AFTER CALLING TRANSFORMPROPERTIES() METHOD.

- Fix for Bug#20391832, SETOBJECT() FOR TYPES.TIME RESULTS IN EXCEPTION WHEN VALUE HAS FRACTIONAL PART.

- Fix for Bug#97730 (31699993), xdev api: ConcurrentModificationException at Session.close.
Expand Down
4 changes: 2 additions & 2 deletions src/main/core-api/java/com/mysql/cj/conf/ConnectionUrl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates.
* Copyright (c) 2016, 2021, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0, as published by the
Expand Down Expand Up @@ -727,7 +727,7 @@ protected HostInfo buildHostInfo(String host, int port, String user, String pass

Properties transformedProps = this.propertiesTransformer.transformProperties(props);

host = transformedProps.getProperty(PropertyKey.PORT.getKeyName());
host = transformedProps.getProperty(PropertyKey.HOST.getKeyName());
try {
port = Integer.parseInt(transformedProps.getProperty(PropertyKey.PORT.getKeyName()));
} catch (NumberFormatException e) {
Expand Down
29 changes: 28 additions & 1 deletion src/test/java/testsuite/regression/ConnectionRegressionTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2020, Oracle and/or its affiliates.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0, as published by the
Expand Down Expand Up @@ -127,6 +127,7 @@
import com.mysql.cj.Query;
import com.mysql.cj.ServerVersion;
import com.mysql.cj.Session;
import com.mysql.cj.conf.ConnectionPropertiesTransform;
import com.mysql.cj.conf.ConnectionUrl;
import com.mysql.cj.conf.HostInfo;
import com.mysql.cj.conf.PropertyDefinitions;
Expand Down Expand Up @@ -11769,4 +11770,30 @@ public void testDefaultUserWithPasswordAuthentication() throws Exception {

assertFalse(authenticationPluginsTested.isEmpty());
}

/**
* Tests fix for Bug#101596 (32151143), GET THE 'HOST' PROPERTY ERROR AFTER CALLING TRANSFORMPROPERTIES() METHOD.
*
* @throws Exception
*/
@Test
public void testBug101596() throws Exception {
Connection testConn = null;
try {
String transformClassName = TestBug101596Transformer.class.getName();
Properties props = new Properties();
props.setProperty(PropertyKey.propertiesTransform.getKeyName(), transformClassName);
testConn = getConnectionWithProps(props); // it was failing before the fix
} finally {
if (testConn != null) {
testConn.close();
}
}
}

public static class TestBug101596Transformer implements ConnectionPropertiesTransform {
public Properties transformProperties(Properties props) {
return props;
}
}
}

0 comments on commit 52479cc

Please sign in to comment.