Skip to content

Commit ff65b32

Browse files
committed
WL#15747, Remove autoDeserialize feature.
Change-Id: I4be14c5219ba457e10c747d89b994100a6841fac
1 parent 0093437 commit ff65b32

File tree

8 files changed

+48
-118
lines changed

8 files changed

+48
-118
lines changed

CHANGES

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

44
Version 8.2.0
55

6+
- WL#15747, Remove autoDeserialize feature.
7+
68
- Fix for Bug#35358417, MySQL Connector/J is not parsing the sessionStateChanges from the OK_Packet correctly.
79

810
- WL#15845, Stop building artifacts for old maven coordinates.

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,6 @@ public enum DatabaseTerm {
519519
//
520520
// CATEGORY_BLOBS
521521
//
522-
new BooleanPropertyDefinition(PropertyKey.autoDeserialize, DEFAULT_VALUE_FALSE, RUNTIME_MODIFIABLE,
523-
Messages.getString("ConnectionProperties.autoDeserialize"), "3.1.5", CATEGORY_BLOBS, Integer.MIN_VALUE),
524-
525522
new MemorySizePropertyDefinition(PropertyKey.blobSendChunkSize, 1024 * 1024, RUNTIME_MODIFIABLE,
526523
Messages.getString("ConnectionProperties.blobSendChunkSize"), "3.1.9", CATEGORY_BLOBS, Integer.MIN_VALUE, 0, 0),
527524

@@ -785,8 +782,9 @@ public enum DatabaseTerm {
785782
new BooleanPropertyDefinition(PropertyKey.gatherPerfMetrics, DEFAULT_VALUE_FALSE, RUNTIME_MODIFIABLE,
786783
Messages.getString("ConnectionProperties.gatherPerfMetrics"), "3.1.2", CATEGORY_DEBUGING_PROFILING, 10),
787784

785+
// TODO currently is not used !!!
788786
new IntegerPropertyDefinition(PropertyKey.reportMetricsIntervalMillis, 30000, RUNTIME_MODIFIABLE,
789-
Messages.getString("ConnectionProperties.reportMetricsIntervalMillis"), "3.1.2", CATEGORY_DEBUGING_PROFILING, 11, 0, Integer.MAX_VALUE), // TODO currently is not used !!!
787+
Messages.getString("ConnectionProperties.reportMetricsIntervalMillis"), "3.1.2", CATEGORY_DEBUGING_PROFILING, 11, 0, Integer.MAX_VALUE),
790788

791789
new BooleanPropertyDefinition(PropertyKey.logXaCommands, DEFAULT_VALUE_FALSE, RUNTIME_MODIFIABLE,
792790
Messages.getString("ConnectionProperties.logXaCommands"), "5.0.5", CATEGORY_DEBUGING_PROFILING, 12),

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public enum PropertyKey {
7373
authenticationFidoCallbackHandler("authenticationFidoCallbackHandler", true), //
7474
authenticationPlugins("authenticationPlugins", true), //
7575
autoClosePStmtStreams("autoClosePStmtStreams", true), //
76-
autoDeserialize("autoDeserialize", true), //
7776
autoGenerateTestcaseScript("autoGenerateTestcaseScript", true), //
7877
autoReconnect("autoReconnect", true), //
7978
autoReconnectForPools("autoReconnectForPools", true), //

src/main/resources/com/mysql/cj/LocalizedErrorMessages.properties

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ Connection.BadExceptionInterceptor=Unable to load exception interceptor.
154154
Connection.CantDetectLocalConnect=Unable to determine if hostname ''{0}'' is local to this box because of exception, assuming it''s not.
155155
Connection.NoMetadataOnSocketFactory=Configured socket factory does not implement SocketMetadata, can not determine whether server is locally-connected, assuming not"
156156
Connection.LoginTimeout=Connection attempt exceeded defined timeout.
157-
Connection.WarnAutoDeserialize=This connection is using the auto-deserialization feature (''autoDeserialize=true'') which is deprecated and will be removed in a future release of MySQL Connector/J.
158157

159158
ConnectionGroup.0=Cannot remove host, only one configured host active.
160159
ConnectionGroup.1=Host is not configured: {0}
@@ -470,9 +469,6 @@ ResultSet.___in_column__212='' in column
470469
ResultSet.Invalid_value_for_getShort()_-____217=Invalid value for getShort() - ''
471470
ResultSet.___in_column__218='' in column
472471

473-
ResultSet.Class_not_found___91=Class not found:
474-
ResultSet._while_reading_serialized_object_92=\ while reading serialized object
475-
476472
ResultSet.Invalid_value_for_getShort()_-____96=Invalid value for getShort() - ''
477473
ResultSet.Unsupported_character_encoding____101=Unsupported character encoding ''
478474

@@ -809,7 +805,6 @@ ConnectionProperties.alwaysSendSetIsolation=Should the driver always communicate
809805
ConnectionProperties.authenticationPlugins=Comma-delimited list of classes that implement the interface ''com.mysql.cj.protocol.AuthenticationPlugin''. These plugins will be loaded at connection initialization and can be used together with their sever-side counterparts for authenticating users, unless they are also disabled in the connection property ''disabledAuthenticationPlugins''.
810806
ConnectionProperties.authenticationFidoCallbackHandler=Fully-qualified class name of a class implementing the interface ''com.mysql.cj.callback.MysqlCallbackHandler''. This class will be used by the FIDO authentication plugin to obtain the authenticator data and signature required for the FIDO authentication process. See the documentation of ''com.mysql.cj.callback.FidoAuthenticationCallback'' for more details.
811807
ConnectionProperties.autoClosePstmtStreams=Should the driver automatically call the method ''close()'' on streams/readers passed as arguments via ''set*()'' methods?
812-
ConnectionProperties.autoDeserialize=Should the driver automatically detect and de-serialize objects stored in BLOB fields?
813808
ConnectionProperties.autoGenerateTestcaseScript=Should the driver dump the SQL it is executing, including server-side prepared statements to STDERR?
814809
ConnectionProperties.autoReconnect=Should the driver try to re-establish stale and/or dead connections? If enabled the driver will throw an exception for queries issued on a stale or dead connection, which belong to the current transaction, but will attempt reconnect before the next query issued on the connection in a new transaction. The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don''t handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Alternatively, as a last option, investigate setting the MySQL server variable ''wait_timeout'' to a high value, rather than the default of 8 hours.
815810
ConnectionProperties.autoReconnectForPools=Use a reconnection strategy appropriate for connection pools?

src/main/user-impl/java/com/mysql/cj/jdbc/ConnectionImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,6 @@ public ConnectionImpl(HostInfo hostInfo) throws SQLException {
428428
this.propertySet.getProperty(PropertyKey.socketFactory).setValue(SocksProxySocketFactory.class.getName());
429429
}
430430

431-
if (this.propertySet.getBooleanProperty(PropertyKey.autoDeserialize.getKeyName()).getValue()) {
432-
this.session.getLog().logWarn(Messages.getString("Connection.WarnAutoDeserialize"));
433-
}
434-
435431
this.dbmd = getMetaData(false, false);
436432
initializeSafeQueryInterceptors();
437433
} catch (CJException e) {

src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java

Lines changed: 21 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@
2929

3030
package com.mysql.cj.jdbc.result;
3131

32-
import java.io.ByteArrayInputStream;
33-
import java.io.IOException;
3432
import java.io.InputStream;
3533
import java.io.InputStreamReader;
36-
import java.io.ObjectInputStream;
3734
import java.io.Reader;
3835
import java.io.UnsupportedEncodingException;
3936
import java.math.BigDecimal;
@@ -384,35 +381,31 @@ public boolean absolute(int row) throws SQLException {
384381

385382
if (this.rowData.size() == 0) {
386383
b = false;
387-
} else {
388-
if (row == 0) {
384+
} else if (row == 0) {
385+
beforeFirst();
386+
b = false;
387+
} else if (row == 1) {
388+
b = first();
389+
} else if (row == -1) {
390+
b = last();
391+
} else if (row > this.rowData.size()) {
392+
afterLast();
393+
b = false;
394+
} else if (row < 0) {
395+
// adjust to reflect after end of result set
396+
int newRowPosition = this.rowData.size() + row + 1;
397+
398+
if (newRowPosition <= 0) {
389399
beforeFirst();
390400
b = false;
391-
} else if (row == 1) {
392-
b = first();
393-
} else if (row == -1) {
394-
b = last();
395-
} else if (row > this.rowData.size()) {
396-
afterLast();
397-
b = false;
398401
} else {
399-
if (row < 0) {
400-
// adjust to reflect after end of result set
401-
int newRowPosition = this.rowData.size() + row + 1;
402-
403-
if (newRowPosition <= 0) {
404-
beforeFirst();
405-
b = false;
406-
} else {
407-
b = absolute(newRowPosition);
408-
}
409-
} else {
410-
row--; // adjust for index difference
411-
this.rowData.setCurrentRow(row);
412-
this.thisRow = this.rowData.get(row);
413-
b = true;
414-
}
402+
b = absolute(newRowPosition);
415403
}
404+
} else {
405+
row--; // adjust for index difference
406+
this.rowData.setCurrentRow(row);
407+
this.thisRow = this.rowData.get(row);
408+
b = true;
416409
}
417410

418411
setRowPositionValidity();
@@ -1130,33 +1123,6 @@ public Object getObject(int columnIndex) throws SQLException {
11301123
// TODO Field sets binary and blob flags if the length of BIT field is > 1; is it needed at all?
11311124
if (field.isBinary() || field.isBlob()) {
11321125
byte[] data = getBytes(columnIndex);
1133-
1134-
if (this.connection.getPropertySet().getBooleanProperty(PropertyKey.autoDeserialize).getValue()) {
1135-
Object obj = data;
1136-
1137-
if (data != null && data.length >= 2) {
1138-
if (data[0] == -84 && data[1] == -19) {
1139-
// Serialized object?
1140-
try {
1141-
ByteArrayInputStream bytesIn = new ByteArrayInputStream(data);
1142-
ObjectInputStream objIn = new ObjectInputStream(bytesIn);
1143-
obj = objIn.readObject();
1144-
objIn.close();
1145-
bytesIn.close();
1146-
} catch (ClassNotFoundException cnfe) {
1147-
throw SQLError.createSQLException(Messages.getString("ResultSet.Class_not_found___91") + cnfe.toString()
1148-
+ Messages.getString("ResultSet._while_reading_serialized_object_92"), getExceptionInterceptor());
1149-
} catch (IOException ex) {
1150-
obj = data; // not serialized?
1151-
}
1152-
} else {
1153-
return getString(columnIndex);
1154-
}
1155-
}
1156-
1157-
return obj;
1158-
}
1159-
11601126
return data;
11611127
}
11621128

@@ -1232,38 +1198,6 @@ public Object getObject(int columnIndex) throws SQLException {
12321198
case MEDIUMBLOB:
12331199
case LONGBLOB:
12341200
case BLOB:
1235-
if (field.isBinary() || field.isBlob()) {
1236-
byte[] data = getBytes(columnIndex);
1237-
1238-
if (this.connection.getPropertySet().getBooleanProperty(PropertyKey.autoDeserialize).getValue()) {
1239-
Object obj = data;
1240-
1241-
if (data != null && data.length >= 2) {
1242-
if (data[0] == -84 && data[1] == -19) {
1243-
// Serialized object?
1244-
try {
1245-
ByteArrayInputStream bytesIn = new ByteArrayInputStream(data);
1246-
ObjectInputStream objIn = new ObjectInputStream(bytesIn);
1247-
obj = objIn.readObject();
1248-
objIn.close();
1249-
bytesIn.close();
1250-
} catch (ClassNotFoundException cnfe) {
1251-
throw SQLError.createSQLException(Messages.getString("ResultSet.Class_not_found___91") + cnfe.toString()
1252-
+ Messages.getString("ResultSet._while_reading_serialized_object_92"), getExceptionInterceptor());
1253-
} catch (IOException ex) {
1254-
obj = data; // not serialized?
1255-
}
1256-
} else {
1257-
return getString(columnIndex);
1258-
}
1259-
}
1260-
1261-
return obj;
1262-
}
1263-
1264-
return data;
1265-
}
1266-
12671201
return getBytes(columnIndex);
12681202

12691203
case YEAR:
@@ -1414,18 +1348,6 @@ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
14141348
return (T) this.thisRow.getValue(columnIndex - 1, new DurationValueFactory(this.session.getPropertySet()));
14151349
}
14161350

1417-
if (this.connection.getPropertySet().getBooleanProperty(PropertyKey.autoDeserialize).getValue()) {
1418-
try {
1419-
return (T) getObject(columnIndex);
1420-
} catch (ClassCastException cce) {
1421-
SQLException sqlEx = SQLError.createSQLException("Conversion not supported for type " + type.getName(),
1422-
MysqlErrorNumbers.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
1423-
sqlEx.initCause(cce);
1424-
1425-
throw sqlEx;
1426-
}
1427-
}
1428-
14291351
throw SQLError.createSQLException("Conversion not supported for type " + type.getName(), MysqlErrorNumbers.SQL_STATE_ILLEGAL_ARGUMENT,
14301352
getExceptionInterceptor());
14311353
}

src/test/java/testsuite/regression/ResultSetRegressionTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
import java.io.ByteArrayInputStream;
4141
import java.io.InputStream;
42+
import java.io.ObjectInputStream;
4243
import java.io.Reader;
4344
import java.io.StringReader;
4445
import java.lang.management.ManagementFactory;
@@ -3038,7 +3039,6 @@ public void testBug25787() throws Exception {
30383039
Properties props = new Properties();
30393040
props.setProperty(PropertyKey.sslMode.getKeyName(), SslMode.DISABLED.name());
30403041
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
3041-
props.setProperty(PropertyKey.autoDeserialize.getKeyName(), "true");
30423042
props.setProperty(PropertyKey.treatUtilDateAsTimestamp.getKeyName(), "false");
30433043

30443044
deserializeConn = getConnectionWithProps(props);
@@ -3051,8 +3051,17 @@ public void testBug25787() throws Exception {
30513051

30523052
this.rs = deserializeConn.createStatement().executeQuery("SELECT MY_OBJECT_FIELD FROM testBug25787");
30533053
this.rs.next();
3054-
assertEquals("java.util.Date", this.rs.getObject(1).getClass().getName());
3055-
assertEquals(dt, this.rs.getObject(1));
3054+
Object data = this.rs.getObject(1);
3055+
assertEquals(byte[].class, data.getClass());
3056+
3057+
ByteArrayInputStream bytesInStream = new ByteArrayInputStream((byte[]) data);
3058+
ObjectInputStream objInStream = new ObjectInputStream(bytesInStream);
3059+
Object obj = objInStream.readObject();
3060+
objInStream.close();
3061+
bytesInStream.close();
3062+
3063+
assertEquals(java.util.Date.class, obj.getClass());
3064+
assertEquals(dt, obj);
30563065
}
30573066

30583067
@Test

src/test/java/testsuite/simple/StatementsTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import java.io.ByteArrayOutputStream;
4343
import java.io.CharArrayReader;
4444
import java.io.InputStream;
45+
import java.io.ObjectInputStream;
4546
import java.io.Reader;
4647
import java.io.StringReader;
4748
import java.lang.reflect.Field;
@@ -1766,7 +1767,6 @@ public void testParameterBindings() throws Exception {
17661767
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
17671768
props.setProperty(PropertyKey.characterEncoding.getKeyName(), "UTF-8");
17681769
props.setProperty(PropertyKey.treatUtilDateAsTimestamp.getKeyName(), "false");
1769-
props.setProperty(PropertyKey.autoDeserialize.getKeyName(), "true");
17701770

17711771
for (boolean useSPS : new boolean[] { false, true }) {
17721772
props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), Boolean.toString(useSPS));
@@ -1808,7 +1808,16 @@ public void testParameterBindings() throws Exception {
18081808
if (boundObject instanceof Number) {
18091809
assertEquals(valuesToTest[i].toString(), boundObject.toString(),
18101810
"For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass);
1811-
} else if (boundObject instanceof Date) {
1811+
} else if (boundObject instanceof byte[]) {
1812+
// Deserialize java.util.Date value.
1813+
ByteArrayInputStream bytesInStream = new ByteArrayInputStream((byte[]) boundObject);
1814+
ObjectInputStream objInStream = new ObjectInputStream(bytesInStream);
1815+
Object obj = objInStream.readObject();
1816+
objInStream.close();
1817+
bytesInStream.close();
1818+
1819+
assertEquals(java.util.Date.class, obj.getClass());
1820+
assertEquals(valuesToTest[i], obj, "For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass);
18121821

18131822
} else {
18141823
assertEquals(valuesToTest[i], boundObject, "For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass);

0 commit comments

Comments
 (0)