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.42
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.43
Choose a head ref
  • 15 commits
  • 28 files changed
  • 2 contributors

Commits on Apr 13, 2017

  1. Post-release changes.

    fjssilva committed Apr 13, 2017
    Copy the full SHA
    41faf9f View commit details

Commits on Apr 20, 2017

  1. Copy the full SHA
    eb4a8a5 View commit details

Commits on Apr 24, 2017

  1. Copy the full SHA
    1454b5c View commit details

Commits on May 19, 2017

  1. Fix for Bug#26090721, CONNECTION FAILING WHEN SERVER STARTED WITH

    COLLATION UTF8MB4_DE_PB_0900_AI_CI.
    soklakov committed May 19, 2017
    Copy the full SHA
    05c1698 View commit details

Commits on Jun 9, 2017

  1. Copy the full SHA
    66494fd View commit details
  2. Copy the full SHA
    c16dc43 View commit details

Commits on Jun 13, 2017

  1. Copy the full SHA
    4e93573 View commit details
  2. Fix for Bug#25650305, GETDATE(),GETTIME() AND GETTIMESTAMP() CALL WITH

    NULL CALENDAR RETURNS NPE.
    soklakov committed Jun 13, 2017
    Copy the full SHA
    6b83353 View commit details

Commits on Jun 26, 2017

  1. Fixed typo in testBug73775.

    soklakov committed Jun 26, 2017
    Copy the full SHA
    86e24f4 View commit details
  2. Copy the full SHA
    109e7a5 View commit details

Commits on Jul 3, 2017

  1. Fix for Bug#74932 (20066806), ConnectionImp Doesn't Close Server Prep…

    …ared Statement (PreparedStatement Leak).
    fjssilva committed Jul 3, 2017
    Copy the full SHA
    05201b0 View commit details
  2. Fix for Bug#85885 (25874048), resultSetConcurrency and resultSetType …

    …are swapped in call to prepareStatement.
    fjssilva committed Jul 3, 2017
    Copy the full SHA
    0844049 View commit details
  3. Copy the full SHA
    2b23399 View commit details

Commits on Jul 4, 2017

  1. Copy the full SHA
    bacf5a1 View commit details

Commits on Jul 6, 2017

  1. Copy the full SHA
    1d14b69 View commit details
Showing with 929 additions and 355 deletions.
  1. +23 −0 CHANGES
  2. +1 −1 build.xml
  3. +47 −6 src/com/mysql/jdbc/ConnectionImpl.java
  4. +5 −1 src/com/mysql/jdbc/ConnectionProperties.java
  5. +11 −0 src/com/mysql/jdbc/ConnectionPropertiesImpl.java
  6. +51 −49 src/com/mysql/jdbc/ExportControlled.java
  7. +6 −3 src/com/mysql/jdbc/LoadBalancedConnectionProxy.java
  8. +2 −1 src/com/mysql/jdbc/LocalizedErrorMessages.properties
  9. +6 −1 src/com/mysql/jdbc/MultiHostConnectionProxy.java
  10. +8 −0 src/com/mysql/jdbc/MultiHostMySQLConnection.java
  11. +1 −1 src/com/mysql/jdbc/MysqlDefs.java
  12. +2 −2 src/com/mysql/jdbc/ResultSetImpl.java
  13. +72 −0 src/com/mysql/jdbc/ServerAffinityStrategy.java
  14. +3 −3 src/com/mysql/jdbc/ServerPreparedStatement.java
  15. +58 −114 src/com/mysql/jdbc/TimeZoneMapping.properties
  16. +6 −1 src/com/mysql/jdbc/interceptors/ResultSetScannerInterceptor.java
  17. +9 −1 src/com/mysql/jdbc/jdbc2/optional/ConnectionWrapper.java
  18. +5 −0 src/com/mysql/jdbc/jdbc2/optional/WrapperBase.java
  19. +6 −1 src/testsuite/perf/RetrievalPerfTest.java
  20. +9 −2 src/testsuite/regression/ConnectionRegressionTest.java
  21. +1 −1 src/testsuite/regression/MetaDataRegressionTest.java
  22. +44 −0 src/testsuite/regression/ResultSetRegressionTest.java
  23. +167 −0 src/testsuite/regression/StatementRegressionTest.java
  24. +115 −51 src/testsuite/regression/SyntaxRegressionTest.java
  25. +55 −111 src/testsuite/regression/UtilsRegressionTest.java
  26. +2 −2 src/testsuite/regression/jdbc4/MetaDataRegressionTest.java
  27. +121 −1 src/testsuite/regression/jdbc4/StatementRegressionTest.java
  28. +93 −2 src/testsuite/simple/MultiHostConnectionTest.java
23 changes: 23 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
# Changelog
# https://dev.mysql.com/doc/relnotes/connector-j/5.1/en/

Version 5.1.43

- Fix for Bug#26399958, UNABLE TO CONNECT TO MYSQL 8.0.3.

- Fix for Bug#78313 (21931572), proxies not handling Object.equals(Object) calls correctly.

- Fix for Bug#85885 (25874048), resultSetConcurrency and resultSetType are swapped in call to prepareStatement.

- Fix for Bug#74932 (20066806), ConnectionImp Doesn't Close Server Prepared Statement (PreparedStatement Leak).

- WL#10536, Deprecating COM_SHUTDOWN.

- Fix for Bug#25650305, GETDATE(),GETTIME() AND GETTIMESTAMP() CALL WITH NULL CALENDAR RETURNS NPE.

- Fix for Bug#26239946, C/J 5.1 GIS TESTS ARE FAILING WITH MYSQL 8.0.1.

- Fix for Bug#26090721, CONNECTION FAILING WHEN SERVER STARTED WITH COLLATION UTF8MB4_DE_PB_0900_AI_CI.

- Fix for Bug#25946965, UPDATE THE TIME ZONE MAPPINGS WITH LATEST TZ DATABASES.

- Fix for Bug#20182108, INCLUDE CUSTOM LOAD BALANCING STRATEGY USING PLUGIN API.
New load-balancing strategy "serverAffinity" and new connection property "serverAffinityOrder" added.

Version 5.1.42

- Fix for Bug#73775 (19531384), DBMD.getProcedureColumns()/.getFunctionColumns() fail to filter by columnPattern.
2 changes: 1 addition & 1 deletion 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="42" />
<property name="subminor_version" value="43" />
<property name="version_status" value="" />

<property name="version" value="${major_version}.${minor_version}.${subminor_version}${version_status}" />
53 changes: 47 additions & 6 deletions src/com/mysql/jdbc/ConnectionImpl.java
Original file line number Diff line number Diff line change
@@ -2189,6 +2189,10 @@ private void coreConnect(Properties mergedProps) throws SQLException, IOExceptio
// reset max-rows to default value
this.sessionMaxRows = -1;

// preconfigure some server variables which are consulted before their initialization from server
this.serverVariables = new HashMap<String, String>();
this.serverVariables.put("character_set_server", "utf8");

this.io = new MysqlIO(newHost, newPort, mergedProps, getSocketFactoryClassName(), getProxy(), getSocketTimeout(),
this.largeRowSizeThreshold.getValueAsInt());
this.io.doHandshake(this.user, this.password, this.database);
@@ -3236,6 +3240,22 @@ private void initializePropsFromServer() throws SQLException {

buildCollationMapping();

// Trying to workaround server collations with index > 255. Such index doesn't fit into server greeting packet, 0 is sent instead.
// Now we could set io.serverCharsetIndex according to "collation_server" value.
if (this.io.serverCharsetIndex == 0) {
String collationServer = this.serverVariables.get("collation_server");
if (collationServer != null) {
for (int i = 1; i < CharsetMapping.COLLATION_INDEX_TO_COLLATION_NAME.length; i++) {
if (CharsetMapping.COLLATION_INDEX_TO_COLLATION_NAME[i].equals(collationServer)) {
this.io.serverCharsetIndex = i;
}
}
} else {
// We can't do more, just trying to use utf8mb4_general_ci because the most of collations in that range are utf8mb4.
this.io.serverCharsetIndex = 45;
}
}

LicenseConfiguration.checkLicenseType(this.serverVariables);

String lowerCaseTables = this.serverVariables.get("lower_case_table_names");
@@ -3378,8 +3398,9 @@ private void initializePropsFromServer() throws SQLException {
setupServerForTruncationChecks();
}

private boolean isQueryCacheEnabled() {
return "ON".equalsIgnoreCase(this.serverVariables.get("query_cache_type")) && !"0".equalsIgnoreCase(this.serverVariables.get("query_cache_size"));
public boolean isQueryCacheEnabled() {
return "YES".equalsIgnoreCase(this.serverVariables.get("have_query_cache")) && "ON".equalsIgnoreCase(this.serverVariables.get("query_cache_type"))
&& !"0".equalsIgnoreCase(this.serverVariables.get("query_cache_size"));
}

private int getServerVariableAsInt(String variableName, int fallbackValue) throws SQLException {
@@ -3745,6 +3766,7 @@ private void loadServerVariables() throws SQLException {
queryBuf.append(", @@character_set_connection AS character_set_connection");
queryBuf.append(", @@character_set_results AS character_set_results");
queryBuf.append(", @@character_set_server AS character_set_server");
queryBuf.append(", @@collation_server AS collation_server");
queryBuf.append(", @@init_connect AS init_connect");
queryBuf.append(", @@interactive_timeout AS interactive_timeout");
if (!versionMeetsMinimum(5, 5, 0)) {
@@ -3755,8 +3777,7 @@ private void loadServerVariables() throws SQLException {
queryBuf.append(", @@max_allowed_packet AS max_allowed_packet");
queryBuf.append(", @@net_buffer_length AS net_buffer_length");
queryBuf.append(", @@net_write_timeout AS net_write_timeout");
queryBuf.append(", @@query_cache_size AS query_cache_size");
queryBuf.append(", @@query_cache_type AS query_cache_type");
queryBuf.append(", @@have_query_cache AS have_query_cache");
queryBuf.append(", @@sql_mode AS sql_mode");
queryBuf.append(", @@system_time_zone AS system_time_zone");
queryBuf.append(", @@time_zone AS time_zone");
@@ -3770,6 +3791,18 @@ private void loadServerVariables() throws SQLException {
this.serverVariables.put(rsmd.getColumnLabel(i), results.getString(i));
}
}

if ("YES".equalsIgnoreCase(this.serverVariables.get("have_query_cache"))) {
results.close();
results = stmt.executeQuery("SELECT @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type");
if (results.next()) {
ResultSetMetaData rsmd = results.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
this.serverVariables.put(rsmd.getColumnLabel(i), results.getString(i));
}
}
}

} else {
results = stmt.executeQuery(versionComment + "SHOW VARIABLES");
while (results.next()) {
@@ -4252,7 +4285,11 @@ public void recachePreparedStatement(ServerPreparedStatement pstmt) throws SQLEx
synchronized (getConnectionMutex()) {
if (getCachePreparedStatements() && pstmt.isPoolable()) {
synchronized (this.serverSideStatementCache) {
this.serverSideStatementCache.put(makePreparedStatementCacheKey(pstmt.currentCatalog, pstmt.originalSql), pstmt);
Object oldServerPrepStmt = this.serverSideStatementCache.put(makePreparedStatementCacheKey(pstmt.currentCatalog, pstmt.originalSql), pstmt);
if (oldServerPrepStmt != null) {
((ServerPreparedStatement) oldServerPrepStmt).isCached = false;
((ServerPreparedStatement) oldServerPrepStmt).realClose(true, true);
}
}
}
}
@@ -5126,7 +5163,11 @@ private void setupServerForTruncationChecks() throws SQLException {
*/
public void shutdownServer() throws SQLException {
try {
this.io.sendCommand(MysqlDefs.SHUTDOWN, null, null, false, null, 0);
if (versionMeetsMinimum(5, 7, 9)) {
execSQL(null, "SHUTDOWN", -1, null, DEFAULT_RESULT_SET_TYPE, DEFAULT_RESULT_SET_CONCURRENCY, false, this.database, null, false);
} else {
this.io.sendCommand(MysqlDefs.SHUTDOWN, null, null, false, null, 0);
}
} catch (Exception ex) {
SQLException sqlEx = SQLError.createSQLException(Messages.getString("Connection.UnhandledExceptionDuringShutdown"),
SQLError.SQL_STATE_GENERAL_ERROR, getExceptionInterceptor());
6 changes: 5 additions & 1 deletion src/com/mysql/jdbc/ConnectionProperties.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2002, 2017, 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.
@@ -1158,6 +1158,10 @@ public interface ConnectionProperties {

public void setLoadBalanceStrategy(String strategy);

public String getServerAffinityOrder();

public void setServerAffinityOrder(String hostsList);

public boolean getTcpNoDelay();

public void setTcpNoDelay(boolean flag);
11 changes: 11 additions & 0 deletions src/com/mysql/jdbc/ConnectionPropertiesImpl.java
Original file line number Diff line number Diff line change
@@ -877,6 +877,9 @@ protected static DriverPropertyInfo[] exposeAsDriverPropertyInfo(Properties info
private StringConnectionProperty loadBalanceStrategy = new StringConnectionProperty("loadBalanceStrategy", "random", null,
Messages.getString("ConnectionProperties.loadBalanceStrategy"), "5.0.6", PERFORMANCE_CATEGORY, Integer.MIN_VALUE);

private StringConnectionProperty serverAffinityOrder = new StringConnectionProperty("serverAffinityOrder", "", null,
Messages.getString("ConnectionProperties.serverAffinityOrder"), "5.1.4.", PERFORMANCE_CATEGORY, Integer.MIN_VALUE);

private IntegerConnectionProperty loadBalanceBlacklistTimeout = new IntegerConnectionProperty("loadBalanceBlacklistTimeout", 0, 0, Integer.MAX_VALUE,
Messages.getString("ConnectionProperties.loadBalanceBlacklistTimeout"), "5.1.0", MISC_CATEGORY, Integer.MIN_VALUE);

@@ -4393,6 +4396,14 @@ public void setLoadBalanceStrategy(String strategy) {
this.loadBalanceStrategy.setValue(strategy);
}

public String getServerAffinityOrder() {
return this.serverAffinityOrder.getValueAsString();
}

public void setServerAffinityOrder(String hostsList) {
this.serverAffinityOrder.setValue(hostsList);
}

public boolean getTcpNoDelay() {
return this.tcpNoDelay.getValueAsBoolean();
}
100 changes: 51 additions & 49 deletions src/com/mysql/jdbc/ExportControlled.java
Original file line number Diff line number Diff line change
@@ -46,15 +46,18 @@
import java.security.cert.CertificateFactory;
import java.security.cert.PKIXCertPathValidatorResult;
import java.security.cert.PKIXParameters;
import java.security.cert.TrustAnchor;
import java.security.cert.X509CertSelector;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;

import javax.crypto.Cipher;
import javax.net.ssl.KeyManager;
@@ -226,21 +229,24 @@ public static class X509TrustManagerWrapper implements X509TrustManager {
private PKIXParameters validatorParams = null;
private CertPathValidator validator = null;

public X509TrustManagerWrapper(X509TrustManager tm, boolean verifyServerCertificate, KeyStore trustKeyStore) throws CertificateException {
public X509TrustManagerWrapper(X509TrustManager tm, boolean verifyServerCertificate) throws CertificateException {
this.origTm = tm;
this.verifyServerCert = verifyServerCertificate;

if (verifyServerCertificate) {
try {
this.validatorParams = new PKIXParameters(trustKeyStore);
Set<TrustAnchor> anch = new HashSet<TrustAnchor>();
for (X509Certificate cert : tm.getAcceptedIssuers()) {
anch.add(new TrustAnchor(cert, null));
}
this.validatorParams = new PKIXParameters(anch);
this.validatorParams.setRevocationEnabled(false);
this.validator = CertPathValidator.getInstance("PKIX");
this.certFactory = CertificateFactory.getInstance("X.509");
} catch (Exception e) {
throw new CertificateException(e);
}
}

}

public X509TrustManagerWrapper() {
@@ -385,56 +391,52 @@ private static SSLSocketFactory getSSLSocketFactoryDefaultOrConfigured(MysqlIO m
}
}

if (!StringUtils.isNullOrEmpty(trustCertificateKeyStoreUrl)) {
InputStream trustStoreIS = null;
try {
KeyStore trustKeyStore = null;

InputStream ksIS = null;
try {
if (!StringUtils.isNullOrEmpty(trustCertificateKeyStoreType)) {
KeyStore trustKeyStore = KeyStore.getInstance(trustCertificateKeyStoreType);
URL ksURL = new URL(trustCertificateKeyStoreUrl);
if (!StringUtils.isNullOrEmpty(trustCertificateKeyStoreUrl) && !StringUtils.isNullOrEmpty(trustCertificateKeyStoreType)) {
trustStoreIS = new URL(trustCertificateKeyStoreUrl).openStream();
char[] trustStorePassword = (trustCertificateKeyStorePassword == null) ? new char[0] : trustCertificateKeyStorePassword.toCharArray();

char[] password = (trustCertificateKeyStorePassword == null) ? new char[0] : trustCertificateKeyStorePassword.toCharArray();
ksIS = ksURL.openStream();
trustKeyStore.load(ksIS, password);
tmf.init(trustKeyStore);

// building the customized list of TrustManagers from original one if it's available
TrustManager[] origTms = tmf.getTrustManagers();
final boolean verifyServerCertificate = mysqlIO.connection.getVerifyServerCertificate();

for (int j = 0; j < origTms.length; j++) {
tms.add(origTms[j] instanceof X509TrustManager
? new X509TrustManagerWrapper((X509TrustManager) origTms[j], verifyServerCertificate, trustKeyStore) // wrapping X509TrustManagers
: origTms[j] // for non-X509 TrustManagers putting original ones
);
}
}
} catch (NoSuchAlgorithmException nsae) {
throw SQLError.createSQLException("Unsupported keystore algorithm [" + nsae.getMessage() + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false,
mysqlIO.getExceptionInterceptor());
} catch (KeyStoreException kse) {
throw SQLError.createSQLException("Could not create KeyStore instance [" + kse.getMessage() + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false,
mysqlIO.getExceptionInterceptor());
} catch (CertificateException nsae) {
throw SQLError.createSQLException("Could not load trust" + trustCertificateKeyStoreType + " keystore from " + trustCertificateKeyStoreUrl,
SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
} catch (MalformedURLException mue) {
throw SQLError.createSQLException(trustCertificateKeyStoreUrl + " does not appear to be a valid URL.", SQL_STATE_BAD_SSL_PARAMS, 0, false,
mysqlIO.getExceptionInterceptor());
} catch (IOException ioe) {
SQLException sqlEx = SQLError.createSQLException("Cannot open " + trustCertificateKeyStoreUrl + " [" + ioe.getMessage() + "]",
SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
trustKeyStore = KeyStore.getInstance(trustCertificateKeyStoreType);
trustKeyStore.load(trustStoreIS, trustStorePassword);
}

sqlEx.initCause(ioe);
tmf.init(trustKeyStore); // (trustKeyStore == null) initializes the TrustManagerFactory with the default truststore.

throw sqlEx;
} finally {
if (ksIS != null) {
try {
ksIS.close();
} catch (IOException e) {
// can't close input stream, but keystore can be properly initialized so we shouldn't throw this exception
}
// building the customized list of TrustManagers from original one if it's available
TrustManager[] origTms = tmf.getTrustManagers();
final boolean verifyServerCert = mysqlIO.connection.getVerifyServerCertificate();

for (TrustManager tm : origTms) {
// wrap X509TrustManager or put original if non-X509 TrustManager
tms.add(tm instanceof X509TrustManager ? new X509TrustManagerWrapper((X509TrustManager) tm, verifyServerCert) : tm);
}

} catch (MalformedURLException e) {
throw SQLError.createSQLException(trustCertificateKeyStoreUrl + " does not appear to be a valid URL.", SQL_STATE_BAD_SSL_PARAMS, 0, false,
mysqlIO.getExceptionInterceptor());
} catch (KeyStoreException e) {
throw SQLError.createSQLException("Could not create KeyStore instance [" + e.getMessage() + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false,
mysqlIO.getExceptionInterceptor());
} catch (NoSuchAlgorithmException e) {
throw SQLError.createSQLException("Unsupported keystore algorithm [" + e.getMessage() + "]", SQL_STATE_BAD_SSL_PARAMS, 0, false,
mysqlIO.getExceptionInterceptor());
} catch (CertificateException e) {
throw SQLError.createSQLException("Could not load trust" + trustCertificateKeyStoreType + " keystore from " + trustCertificateKeyStoreUrl,
SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
} catch (IOException e) {
SQLException sqlEx = SQLError.createSQLException("Cannot open " + trustCertificateKeyStoreType + " [" + e.getMessage() + "]",
SQL_STATE_BAD_SSL_PARAMS, 0, false, mysqlIO.getExceptionInterceptor());
sqlEx.initCause(e);
throw sqlEx;
} finally {
if (trustStoreIS != null) {
try {
trustStoreIS.close();
} catch (IOException e) {
// can't close input stream, but keystore can be properly initialized so we shouldn't throw this exception
}
}
}
Loading