Skip to content

Commit 2ce8cb2

Browse files
committed
Fix for Bug#81128 (Bug#23146631), Master host list overwritten by slave list when loadBalanceConnectionGroup used.
Change-Id: I383b1aa3882d7b6a32eb57e6ccc59d8e308ad5ea
1 parent f889dec commit 2ce8cb2

File tree

14 files changed

+135
-53
lines changed

14 files changed

+135
-53
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
Version 9.5.0
55

6+
- Fix for Bug#81128 (Bug#23146631), Master host list overwritten by slave list when loadBalanceConnectionGroup used.
7+
68
- Fix for Bug#19887224, RUNNING THE TEST SUITE WITH SOCKSPROXY* PROPERTIES HANGS IN TEST TESTBUG56429.
79

810
- Fix for Bug#98699 (Bug#30932850), Allow empty keyStore file for keyStoreTypes that do not require files.

src/main/core-api/java/com/mysql/cj/conf/ConnectionUrl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,10 @@ public List<HostInfo> getHostsListFromDnsSrv(HostInfo srvHost) {
791791
try {
792792
srvRecords = DnsSrv.lookupSrvRecords(srvServiceName);
793793
} catch (NamingException e) {
794-
throw ExceptionFactory.createException(Messages.getString("ConnectionString.26", new Object[] { srvServiceName }), e);
794+
throw ExceptionFactory.createException(Messages.getString("ConnectionString.27", new Object[] { srvServiceName }), e);
795795
}
796796
if (srvRecords == null || srvRecords.size() == 0) {
797-
throw ExceptionFactory.createException(Messages.getString("ConnectionString.26", new Object[] { srvServiceName }));
797+
throw ExceptionFactory.createException(Messages.getString("ConnectionString.27", new Object[] { srvServiceName }));
798798
}
799799

800800
return Collections.unmodifiableList(srvRecordsToHostsList(srvRecords, srvHost));

src/main/core-api/java/com/mysql/cj/conf/ConnectionUrlParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private ConnectionUrlParser(String connString) {
123123
}
124124
if (!isConnectionStringSupported(connString)) {
125125
throw ExceptionFactory.createException(UnsupportedConnectionStringException.class,
126-
Messages.getString("ConnectionString.17", new String[] { connString }));
126+
Messages.getString("ConnectionString.18", new String[] { connString }));
127127
}
128128
this.baseConnectionString = connString;
129129
parseConnectionString();

src/main/core-impl/java/com/mysql/cj/conf/url/FailoverDnsSrvConnectionUrl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,22 @@ public FailoverDnsSrvConnectionUrl(ConnectionUrlParser connStrParser, Properties
6262
HostInfo srvHost = super.getMainHost();
6363
Map<String, String> hostProps = srvHost.getHostProperties();
6464
if (DEFAULT_HOST.equals(srvHost.getHost())) {
65-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.18"));
65+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.19"));
6666
}
6767
if (this.hosts.size() != 1) {
68-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.19"));
68+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.20"));
6969
}
7070
if (srvHost.getPort() != DEFAULT_PORT) {
71-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.22"));
71+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.23"));
7272
}
7373
if (hostProps.containsKey(PropertyKey.dnsSrv.getKeyName())) {
7474
if (!BooleanPropertyDefinition.booleanFrom(PropertyKey.dnsSrv.getKeyName(), hostProps.get(PropertyKey.dnsSrv.getKeyName()), null)) {
7575
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class,
76-
Messages.getString("ConnectionString.23", new Object[] { PropertyKey.dnsSrv.getKeyName() }));
76+
Messages.getString("ConnectionString.24", new Object[] { PropertyKey.dnsSrv.getKeyName() }));
7777
}
7878
}
7979
if (hostProps.containsKey(PropertyKey.PROTOCOL.getKeyName()) && hostProps.get(PropertyKey.PROTOCOL.getKeyName()).equalsIgnoreCase("PIPE")) {
80-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.24"));
80+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.25"));
8181
}
8282
}
8383

src/main/core-impl/java/com/mysql/cj/conf/url/LoadBalanceConnectionUrl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public LoadBalanceConnectionUrl(ConnectionUrlParser connStrParser, Properties in
5454
// for (HostInfo hi : this.hosts) {
5555
// if (visitedHosts.contains(hi.getHostPortPair())) {
5656
// throw ExceptionFactory.createException(WrongArgumentException.class,
57-
// Messages.getString("ConnectionString.12", new Object[] { hi.getHostPortPair(), Type.LOADBALANCE_CONNECTION.getProtocol() }));
57+
// Messages.getString("ConnectionString.12", new Object[] { hi.getHostPortPair(), Type.LOADBALANCE_CONNECTION.getScheme() }));
5858
// }
5959
// visitedHosts.add(hi.getHostPortPair());
6060
// }

src/main/core-impl/java/com/mysql/cj/conf/url/LoadBalanceDnsSrvConnectionUrl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,26 @@ public LoadBalanceDnsSrvConnectionUrl(ConnectionUrlParser connStrParser, Propert
6464
HostInfo srvHost = super.getMainHost();
6565
Map<String, String> hostProps = srvHost.getHostProperties();
6666
if (DEFAULT_HOST.equals(srvHost.getHost())) {
67-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.18"));
67+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.19"));
6868
}
6969
if (this.hosts.size() != 1) {
70-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.19"));
70+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.20"));
7171
}
7272
if (srvHost.getPort() != DEFAULT_PORT) {
73-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.22"));
73+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.23"));
7474
}
7575
if (hostProps.containsKey(PropertyKey.dnsSrv.getKeyName())) {
7676
if (!BooleanPropertyDefinition.booleanFrom(PropertyKey.dnsSrv.getKeyName(), hostProps.get(PropertyKey.dnsSrv.getKeyName()), null)) {
7777
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class,
78-
Messages.getString("ConnectionString.23", new Object[] { PropertyKey.dnsSrv.getKeyName() }));
78+
Messages.getString("ConnectionString.24", new Object[] { PropertyKey.dnsSrv.getKeyName() }));
7979
}
8080
}
8181
if (hostProps.containsKey(PropertyKey.PROTOCOL.getKeyName()) && hostProps.get(PropertyKey.PROTOCOL.getKeyName()).equalsIgnoreCase("PIPE")) {
82-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.24"));
82+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.25"));
8383
}
8484
if (hostProps.containsKey(PropertyKey.loadBalanceConnectionGroup.getKeyName())) {
8585
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class,
86-
Messages.getString("ConnectionString.25", new Object[] { PropertyKey.loadBalanceConnectionGroup.getKeyName() }));
86+
Messages.getString("ConnectionString.26", new Object[] { PropertyKey.loadBalanceConnectionGroup.getKeyName() }));
8787
}
8888
}
8989

src/main/core-impl/java/com/mysql/cj/conf/url/ReplicationConnectionUrl.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@
2828
import java.util.Map;
2929
import java.util.Properties;
3030
import java.util.stream.Collectors;
31+
import java.util.stream.Stream;
3132

33+
import com.mysql.cj.Messages;
3234
import com.mysql.cj.conf.ConnectionUrl;
3335
import com.mysql.cj.conf.ConnectionUrlParser;
3436
import com.mysql.cj.conf.HostInfo;
3537
import com.mysql.cj.conf.HostsListView;
3638
import com.mysql.cj.conf.PropertyKey;
39+
import com.mysql.cj.exceptions.ExceptionFactory;
40+
import com.mysql.cj.exceptions.InvalidConnectionAttributeException;
3741

3842
public class ReplicationConnectionUrl extends ConnectionUrl {
3943

@@ -78,6 +82,16 @@ public ReplicationConnectionUrl(ConnectionUrlParser connStrParser, Properties in
7882
this.replicaHosts.addAll(undefinedHosts);
7983
}
8084

85+
/*
86+
* Validate the hosts list:
87+
* 1. Property 'loadBalanceConnectionGroup' cannot be set.
88+
*/
89+
if (Stream.concat(this.sourceHosts.stream(), this.replicaHosts.stream()).map(HostInfo::getHostProperties)
90+
.anyMatch(p -> p.containsKey(PropertyKey.loadBalanceConnectionGroup.getKeyName()))) {
91+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.14",
92+
new Object[] { PropertyKey.loadBalanceConnectionGroup.getKeyName(), Type.REPLICATION_CONNECTION.getScheme() }));
93+
}
94+
8195
// TODO: Validate the hosts list: there can't be any two hosts with same host:port.
8296
// Although this should be required, it also is incompatible with our current tests which are creating replication connections
8397
// using the same host configurations.
@@ -86,7 +100,7 @@ public ReplicationConnectionUrl(ConnectionUrlParser connStrParser, Properties in
86100
// for (HostInfo hi : hostsLists) {
87101
// if (visitedHosts.contains(hi.getHostPortPair())) {
88102
// throw ExceptionFactory.createException(WrongArgumentException.class,
89-
// Messages.getString("ConnectionString.13", new Object[] { hi.getHostPortPair(), Type.REPLICATION_CONNECTION.getProtocol() }));
103+
// Messages.getString("ConnectionString.13", new Object[] { hi.getHostPortPair(), Type.REPLICATION_CONNECTION.getScheme() }));
90104
// }
91105
// visitedHosts.add(hi.getHostPortPair());
92106
// }

src/main/core-impl/java/com/mysql/cj/conf/url/ReplicationDnsSrvConnectionUrl.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,36 +90,42 @@ public ReplicationDnsSrvConnectionUrl(ConnectionUrlParser connStrParser, Propert
9090
* 4. If property 'dnsSrv' is set then it cannot be "false".
9191
* 5. Property 'protocol' cannot be "PIPE".
9292
* 6. Property 'replicationConnectionGroup' cannot be set.
93+
* 7. Property 'loadBalanceConnectionGroup' cannot be set.
9394
*/
9495
HostInfo srvHostSource = this.sourceHosts.isEmpty() ? null : this.sourceHosts.get(0);
9596
Map<String, String> hostPropsSource = srvHostSource == null ? Collections.emptyMap() : srvHostSource.getHostProperties();
9697
HostInfo srvHostReplica = this.replicaHosts.isEmpty() ? null : this.replicaHosts.get(0);
9798
Map<String, String> hostPropsReplica = srvHostReplica == null ? Collections.emptyMap() : srvHostReplica.getHostProperties();
9899
if (srvHostSource == null || srvHostReplica == null || DEFAULT_HOST.equals(srvHostSource.getHost()) || DEFAULT_HOST.equals(srvHostReplica.getHost())) {
99-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.20"));
100+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.21"));
100101
}
101102
if (this.sourceHosts.size() != 1 || this.replicaHosts.size() != 1) {
102-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.21"));
103+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.22"));
103104
}
104105
if (srvHostSource.getPort() != DEFAULT_PORT || srvHostReplica.getPort() != DEFAULT_PORT) {
105-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.22"));
106+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.23"));
106107
}
107108
if (hostPropsSource.containsKey(PropertyKey.dnsSrv.getKeyName()) || hostPropsReplica.containsKey(PropertyKey.dnsSrv.getKeyName())) {
108109
if (!BooleanPropertyDefinition.booleanFrom(PropertyKey.dnsSrv.getKeyName(), hostPropsSource.get(PropertyKey.dnsSrv.getKeyName()), null)
109110
|| !BooleanPropertyDefinition.booleanFrom(PropertyKey.dnsSrv.getKeyName(), hostPropsReplica.get(PropertyKey.dnsSrv.getKeyName()), null)) {
110111
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class,
111-
Messages.getString("ConnectionString.23", new Object[] { PropertyKey.dnsSrv.getKeyName() }));
112+
Messages.getString("ConnectionString.24", new Object[] { PropertyKey.dnsSrv.getKeyName() }));
112113
}
113114
}
114115
if (hostPropsSource.containsKey(PropertyKey.PROTOCOL.getKeyName()) && hostPropsSource.get(PropertyKey.PROTOCOL.getKeyName()).equalsIgnoreCase("PIPE")
115116
|| hostPropsReplica.containsKey(PropertyKey.PROTOCOL.getKeyName())
116117
&& hostPropsReplica.get(PropertyKey.PROTOCOL.getKeyName()).equalsIgnoreCase("PIPE")) {
117-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.24"));
118+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.25"));
118119
}
119120
if (hostPropsSource.containsKey(PropertyKey.replicationConnectionGroup.getKeyName())
120121
|| hostPropsReplica.containsKey(PropertyKey.replicationConnectionGroup.getKeyName())) {
121122
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class,
122-
Messages.getString("ConnectionString.25", new Object[] { PropertyKey.replicationConnectionGroup.getKeyName() }));
123+
Messages.getString("ConnectionString.26", new Object[] { PropertyKey.replicationConnectionGroup.getKeyName() }));
124+
}
125+
if (hostPropsSource.containsKey(PropertyKey.loadBalanceConnectionGroup.getKeyName())
126+
|| hostPropsReplica.containsKey(PropertyKey.loadBalanceConnectionGroup.getKeyName())) {
127+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class,
128+
Messages.getString("ConnectionString.26", new Object[] { PropertyKey.loadBalanceConnectionGroup.getKeyName() }));
123129
}
124130
}
125131

src/main/core-impl/java/com/mysql/cj/conf/url/XDevApiConnectionUrl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,19 @@ public XDevApiConnectionUrl(ConnectionUrlParser connStrParser, Properties info)
8383
} else {
8484
if (!StringUtils.nullSafeEqual(user, hi.getUser()) || !StringUtils.nullSafeEqual(password, hi.getPassword())) {
8585
throw ExceptionFactory.createException(WrongArgumentException.class,
86-
Messages.getString("ConnectionString.14", new Object[] { Type.XDEVAPI_SESSION.getScheme() }));
86+
Messages.getString("ConnectionString.15", new Object[] { Type.XDEVAPI_SESSION.getScheme() }));
8787
}
8888
if (hasPriority ^ hi.getHostProperties().containsKey(PropertyKey.PRIORITY.getKeyName())) {
8989
throw ExceptionFactory.createException(WrongArgumentException.class,
90-
Messages.getString("ConnectionString.15", new Object[] { Type.XDEVAPI_SESSION.getScheme() }));
90+
Messages.getString("ConnectionString.16", new Object[] { Type.XDEVAPI_SESSION.getScheme() }));
9191
}
9292
}
9393
if (hasPriority) {
9494
try {
9595
int priority = Integer.parseInt(hi.getProperty(PropertyKey.PRIORITY.getKeyName()));
9696
if (priority < 0 || priority > 100) {
9797
throw ExceptionFactory.createException(WrongArgumentException.class,
98-
Messages.getString("ConnectionString.16", new Object[] { Type.XDEVAPI_SESSION.getScheme() }));
98+
Messages.getString("ConnectionString.17", new Object[] { Type.XDEVAPI_SESSION.getScheme() }));
9999
}
100100
if (priorities.contains(priority)) {
101101
this.hasDuplicatedPriorities = true;
@@ -104,7 +104,7 @@ public XDevApiConnectionUrl(ConnectionUrlParser connStrParser, Properties info)
104104
}
105105
} catch (NumberFormatException e) {
106106
throw ExceptionFactory.createException(WrongArgumentException.class,
107-
Messages.getString("ConnectionString.16", new Object[] { Type.XDEVAPI_SESSION.getScheme() }));
107+
Messages.getString("ConnectionString.17", new Object[] { Type.XDEVAPI_SESSION.getScheme() }));
108108
}
109109
}
110110
}

src/main/core-impl/java/com/mysql/cj/conf/url/XDevApiDnsSrvConnectionUrl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@ public XDevApiDnsSrvConnectionUrl(ConnectionUrlParser connStrParser, Properties
6565
HostInfo srvHost = super.getMainHost();
6666
Map<String, String> hostProps = srvHost.getHostProperties();
6767
if (DEFAULT_HOST.equals(srvHost.getHost())) {
68-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.18"));
68+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.19"));
6969
}
7070
if (this.hosts.size() != 1) {
71-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.19"));
71+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.20"));
7272
}
7373
if (srvHost.getPort() != DEFAULT_PORT) {
74-
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.22"));
74+
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class, Messages.getString("ConnectionString.23"));
7575
}
7676
if (hostProps.containsKey(PropertyKey.xdevapiDnsSrv.getKeyName())) {
7777
if (!BooleanPropertyDefinition.booleanFrom(PropertyKey.xdevapiDnsSrv.getKeyName(), hostProps.get(PropertyKey.xdevapiDnsSrv.getKeyName()), null)) {
7878
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class,
79-
Messages.getString("ConnectionString.23", new Object[] { PropertyKey.xdevapiDnsSrv.getKeyName() }));
79+
Messages.getString("ConnectionString.24", new Object[] { PropertyKey.xdevapiDnsSrv.getKeyName() }));
8080
}
8181
}
8282
}

0 commit comments

Comments
 (0)