Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mysql/mysql-connector-j
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5.1.39
Choose a base ref
...
head repository: mysql/mysql-connector-j
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5.1.40
Choose a head ref
Loading
Showing with 1,428 additions and 493 deletions.
  1. +36 −0 CHANGES
  2. +3 −3 build.xml
  3. +24 −7 src/com/mysql/fabric/FabricConnection.java
  4. +13 −4 src/com/mysql/fabric/FabricStateResponse.java
  5. +2 −6 src/com/mysql/fabric/hibernate/FabricMultiTenantConnectionProvider.java
  6. +48 −67 src/com/mysql/fabric/jdbc/FabricMySQLConnectionProxy.java
  7. +9 −2 src/com/mysql/fabric/proto/xmlrpc/XmlRpcClient.java
  8. +21 −14 src/com/mysql/jdbc/CompressedInputStream.java
  9. +8 −8 src/com/mysql/jdbc/ConnectionImpl.java
  10. +27 −39 src/com/mysql/jdbc/DatabaseMetaData.java
  11. +10 −12 src/com/mysql/jdbc/Field.java
  12. +1 −0 src/com/mysql/jdbc/LocalizedErrorMessages.properties
  13. +7 −4 src/com/mysql/jdbc/MysqlDefs.java
  14. +14 −6 src/com/mysql/jdbc/MysqlIO.java
  15. +1 −1 src/com/mysql/jdbc/NonRegisteringDriver.java
  16. +3 −3 src/com/mysql/jdbc/ReplicationConnectionGroup.java
  17. +5 −0 src/com/mysql/jdbc/ReplicationConnectionProxy.java
  18. +86 −98 src/com/mysql/jdbc/ResultSetImpl.java
  19. +5 −4 src/com/mysql/jdbc/SQLError.java
  20. +11 −6 src/com/mysql/jdbc/ServerPreparedStatement.java
  21. +21 −0 src/com/mysql/jdbc/Util.java
  22. +7 −1 src/com/mysql/jdbc/jdbc2/optional/MysqlDataSource.java
  23. +10 −8 src/com/mysql/jdbc/jdbc2/optional/MysqlXAConnection.java
  24. +5 −5 src/demo/fabric/EmployeesDataSource.java
  25. +0 −46 src/testsuite/fabric/jdbc/TestBasicConnection.java
  26. +171 −0 src/testsuite/fabric/jdbc/TestRegressions.java
  27. +91 −1 src/testsuite/regression/ConnectionRegressionTest.java
  28. +14 −0 src/testsuite/regression/DataSourceRegressionTest.java
  29. +5 −1 src/testsuite/regression/MetaDataRegressionTest.java
  30. +308 −7 src/testsuite/regression/ResultSetRegressionTest.java
  31. +222 −19 src/testsuite/regression/StatementRegressionTest.java
  32. +6 −8 src/testsuite/regression/SyntaxRegressionTest.java
  33. +62 −0 src/testsuite/regression/UtilsRegressionTest.java
  34. +3 −1 src/testsuite/simple/CharsetTest.java
  35. +5 −5 src/testsuite/simple/ConnectionTest.java
  36. +22 −23 src/testsuite/ssl-test-certs/ca-cert.pem
  37. +25 −25 src/testsuite/ssl-test-certs/ca-key.pem
  38. +55 −0 src/testsuite/ssl-test-certs/certs_howto.txt
  39. +20 −19 src/testsuite/ssl-test-certs/server-cert.pem
  40. +25 −25 src/testsuite/ssl-test-certs/server-key.pem
  41. +17 −15 src/testsuite/ssl-test-certs/server-req.pem
  42. BIN src/testsuite/ssl-test-certs/test-cert-store
36 changes: 36 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# Changelog
# $Id$
09-30-16 - Version 5.1.40

- Fix for Bug#24619829, NEW FAILURES IN C/JAVA UNITTESTS AGAINST MYSQL 8.0.

- Fix for Bug#75209 (20212882), Set useLocalTransactionState may result in partially committed transaction.

- Fix for Bug#23197238, EXECUTEQUERY() FAILS FOR JSON DATA WHEN RESULTSETCONCURRENCY=CONCUR_UPDATABLE.

- Fix for Bug#48346 (11756431), Communications link failure when reading compressed data with compressed=true.
Thanks to Ryosuke Yamazaki for his contribution.

- Fix for Bug#74711 (19974685), FORGOTTEN WORKAROUND FOR BUG#36326.

- Fix for Bug#80631 (22891845), ResultSet.getString return garbled result with json type data.
Thanks to Dong SongLing for his contribution.

- Fix for Bug#64188 (13702433), MysqlXAConnection.MYSQL_ERROR_CODES_TO_XA_ERROR_CODES is missing XA error codes.

- Fix for Bug#81072 (23103408), FabricMySQLConnectionProxy method nativeSQL does nothing.

- Fix for Bug#81056 (23103406), Connector/J with Fabric always returns lower_case_table_names false.

- Fix for Bug#77649 (21389278), URL start with word "address",JDBC can't parse the "host:port" Correctly.

- Fix for Bug#72632 (18759269), NullPointerException for invalid JDBC URL.

- Fix for Bug#22750465, CONNECTOR/J HANGS WHEN FABRIC NODE IS DOWN.

- Fix for Bug#82094 (23738636), ConcurrentModificationException on Fabric connections after topology changes.

- Fix for Bug#82115 (23743956), Some exceptions are intercepted twice or fail to set the init cause.

- Fix for Bug#78685 (21938551), Wrong results when retrieving the value of a BIT column as an integer.

- Fix for Bug#80615 (22954007), prepared statement leak when rewriteBatchedStatements=true and useServerPrepStmt.

04-29-16 - Version 5.1.39

- Fix for Bug#23212347, ALL API CALLS ON RESULTSET METADATA RESULTS IN NPE WHEN USESERVERPREPSTMTS=TRUE.
6 changes: 3 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@ com.mysql.jdbc.noCleanBetweenCompiles=yes

<property name="major_version" value="5" />
<property name="minor_version" value="1" />
<property name="subminor_version" value="39" />
<property name="subminor_version" value="40" />
<property name="version_status" value="" />

<property name="version" value="${major_version}.${minor_version}.${subminor_version}${version_status}" />
@@ -1663,7 +1663,7 @@ Java 8 (for JDBC 4+ implementation) is also required. Set the full path to this
<sysproperty key="com.mysql.fabric.testsuite.shard2.port" value="${com.mysql.fabric.testsuite.shard2.port}" />

<classpath>
<fileset dir="${com.mysql.jdbc.extra.libs}/hibernate4">
<fileset dir="${com.mysql.jdbc.extra.libs}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${buildDir}/${fullProdName}/lib">
@@ -1750,7 +1750,7 @@ Java 8 (for JDBC 4+ implementation) is also required. Set the full path to this
<sysproperty key="com.mysql.fabric.testsuite.shard2.port" value="${com.mysql.fabric.testsuite.shard2.port}" />

<classpath>
<fileset dir="${com.mysql.jdbc.extra.libs}/hibernate4">
<fileset dir="${com.mysql.jdbc.extra.libs}">
<include name="**/*.jar" />
</fileset>
<fileset dir="src/lib">
31 changes: 24 additions & 7 deletions src/com/mysql/fabric/FabricConnection.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
@@ -26,6 +26,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import com.mysql.fabric.proto.xmlrpc.XmlRpcClient;

@@ -36,7 +37,9 @@ public class FabricConnection {
private Map<String, ShardMapping> shardMappingsByTableName = new HashMap<String, ShardMapping>();
private Map<String, ServerGroup> serverGroupsByName = new HashMap<String, ServerGroup>();
private long shardMappingsExpiration;
private int shardMappingsTtl;
private long serverGroupsExpiration;
private int serverGroupsTtl;

public FabricConnection(String url, String username, String password) throws FabricCommunicationException {
this.client = new XmlRpcClient(url, username, password);
@@ -67,13 +70,15 @@ public int getVersion() {
public int refreshState() throws FabricCommunicationException {
FabricStateResponse<Set<ServerGroup>> serverGroups = this.client.getServerGroups();
FabricStateResponse<Set<ShardMapping>> shardMappings = this.client.getShardMappings();
this.serverGroupsExpiration = serverGroups.getExpireTimeMillis();
this.shardMappingsExpiration = shardMappings.getExpireTimeMillis();

this.serverGroupsExpiration = serverGroups.getExpireTimeMillis();
this.serverGroupsTtl = serverGroups.getTtl();
for (ServerGroup g : serverGroups.getData()) {
this.serverGroupsByName.put(g.getName(), g);
}

this.shardMappingsExpiration = shardMappings.getExpireTimeMillis();
this.shardMappingsTtl = shardMappings.getTtl();
for (ShardMapping m : shardMappings.getData()) {
// a shard mapping may be associated with more than one table
for (ShardTable t : m.getShardTables()) {
@@ -84,16 +89,28 @@ public int refreshState() throws FabricCommunicationException {
return 0;
}

public ServerGroup getServerGroup(String serverGroupName) throws FabricCommunicationException {
public int refreshStatePassive() {
try {
return refreshState();
} catch (FabricCommunicationException e) {
// Fabric node is down but we can operate on previous setup. Just reset the TTL timers.
this.serverGroupsExpiration = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(this.serverGroupsTtl);
this.shardMappingsExpiration = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(this.shardMappingsTtl);
}

return 0;
}

public ServerGroup getServerGroup(String serverGroupName) {
if (isStateExpired()) {
refreshState();
refreshStatePassive();
}
return this.serverGroupsByName.get(serverGroupName);
}

public ShardMapping getShardMapping(String database, String table) throws FabricCommunicationException {
public ShardMapping getShardMapping(String database, String table) {
if (isStateExpired()) {
refreshState();
refreshStatePassive();
}
return this.shardMappingsByTableName.get(database + "." + table);
}
17 changes: 13 additions & 4 deletions src/com/mysql/fabric/FabricStateResponse.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/J is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
@@ -23,24 +23,33 @@

package com.mysql.fabric;

import java.util.concurrent.TimeUnit;

public class FabricStateResponse<T> {
private T data;
private int secsTtl;
private long expireTimeMillis;

public FabricStateResponse(T data, int secsTtl) {
this.data = data;
this.expireTimeMillis = System.currentTimeMillis() + (1000 * secsTtl);
this.secsTtl = secsTtl;
this.expireTimeMillis = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(secsTtl);
}

public FabricStateResponse(T data, long expireTimeMillis) {
public FabricStateResponse(T data, int secsTtl, long presetExpireTimeMillis) {
this.data = data;
this.expireTimeMillis = expireTimeMillis;
this.secsTtl = secsTtl;
this.expireTimeMillis = presetExpireTimeMillis;
}

public T getData() {
return this.data;
}

public int getTtl() {
return this.secsTtl;
}

/**
* The expiration time of this data. Should be compared to {@link System.currentTimeMillis()}.
*/
Original file line number Diff line number Diff line change
@@ -100,12 +100,8 @@ public Connection getAnyConnection() throws SQLException {
*/
public Connection getConnection(String tenantIdentifier) throws SQLException {
String serverGroupName = this.shardMapping.getGroupNameForKey(tenantIdentifier);
try {
ServerGroup serverGroup = this.fabricConnection.getServerGroup(serverGroupName);
return getReadWriteConnectionFromServerGroup(serverGroup);
} catch (FabricCommunicationException ex) {
throw new RuntimeException(ex);
}
ServerGroup serverGroup = this.fabricConnection.getServerGroup(serverGroupName);
return getReadWriteConnectionFromServerGroup(serverGroup);
}

/**
Loading