-
Bug
-
Resolution: Fixed
-
P2
-
6
-
b63
-
generic
-
generic
JCK : jck6.0
J2SE : FAIL - mustang b59
Platform[s] : FAIL - All
switch/Mode : FAIL - default
JCK test owner : http://javaweb.sfbay/jcce/tcks/jck/docs/others/owners.jto
Failing Tests:
===============
api/java_sql/serialization/descriptions.html#SQLException[testRead]
Problem description:
===================
When I am serializing the java.sql.DataTruncation class in JDK 1.5 and
deserializing it in JDK 6.0, the value of DataTruncation.getSQLState()
is not the same.
Please see minimized test to reproduce the failure.
This incompatible serialization change in the java.sql.DataTruncation class
prevents correct serialization/deserialization of DataTruncation
between different versions of J2SE (for example, 1.5.0 <-> 6.0).
Minimized test:
==============
--- Test.java ---
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.sql.SQLException;
import java.sql.DataTruncation;
//Tests object serialization and deserialization of java.sql.DataTruncation.
public class Test {
public static void main(String args[]) throws Exception {
if (args.length < 2) {
printUsage();
System.exit(1);
}
DataTruncation exc = new DataTruncation(10, false, false, 100, 49);
if ("s".equals(args[0])) {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(args[1]));
oos.writeObject(exc);
oos.flush();
oos.close();
System.out.println("OKAY. DataTruncation has been serialized to file: " + args[1]);
System.out.println("DataTruncation value: " + exc.toString());
}
else if ("d".equals(args[0])) {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(args[1]));
DataTruncation obj = (DataTruncation) ois.readObject();
ois.close();
if (exc.getSQLState().equals(obj.getSQLState())) {
System.out.println("OKAY. Deserialization successful.");
System.out.println("DataTruncation value: " + obj.toString());
} else {
System.out.println("FAILED:\n\tExpected:" +
"\n\t" + exc.getSQLState() +
"\n\tReceived: " +
"\n\t" + obj.getSQLState());
}
}
else {
printUsage();
System.exit(1);
}
}
public static void printUsage() {
System.err.println("Usage: java Test [s|d] file");
System.err.println("s - serialize");
System.err.println("d - deserialize");
}
}
--- End-of-Test.java ---
Minimized test output:
=====================
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/javac Test.java
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/java Test s test.ser OKAY. DataTruncation has been serialized to file: test.ser
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/java Test d test.ser OKAY. Deserialization successful.
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/re/jdk/6.0/promoted/beta/b59/binaries/solaris-sparc/bin/java Test s test.ser
OKAY. DataTruncation has been serialized to file: test.ser
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/re/jdk/6.0/promoted/beta/b59/binaries/solaris-sparc/bin/java Test d test.ser
OKAY. Deserialization successful.
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/java Test s test.ser OKAY. DataTruncation has been serialized to file: test.ser
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/re/jdk/6.0/promoted/beta/b59/binaries/solaris-sparc/bin/java Test d test.ser
FAILED:
Expected:
22001
Received:
null
<yg153347@mars> /set/java/re/jdk/6.0/promoted/beta/b59/binaries/solaris-sparc/bin/java Test s test.ser
OKAY. DataTruncation has been serialized to file: test.ser
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/java Test d test.ser FAILED:
Expected:
01004
Received:
null
Specific Machine Info:
=====================
<yg153347@mars> uname -a
SunOS mars 5.9 Generic_117171-09 sun4u sparc SUNW,Ultra-60
J2SE : FAIL - mustang b59
Platform[s] : FAIL - All
switch/Mode : FAIL - default
JCK test owner : http://javaweb.sfbay/jcce/tcks/jck/docs/others/owners.jto
Failing Tests:
===============
api/java_sql/serialization/descriptions.html#SQLException[testRead]
Problem description:
===================
When I am serializing the java.sql.DataTruncation class in JDK 1.5 and
deserializing it in JDK 6.0, the value of DataTruncation.getSQLState()
is not the same.
Please see minimized test to reproduce the failure.
This incompatible serialization change in the java.sql.DataTruncation class
prevents correct serialization/deserialization of DataTruncation
between different versions of J2SE (for example, 1.5.0 <-> 6.0).
Minimized test:
==============
--- Test.java ---
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.sql.SQLException;
import java.sql.DataTruncation;
//Tests object serialization and deserialization of java.sql.DataTruncation.
public class Test {
public static void main(String args[]) throws Exception {
if (args.length < 2) {
printUsage();
System.exit(1);
}
DataTruncation exc = new DataTruncation(10, false, false, 100, 49);
if ("s".equals(args[0])) {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(args[1]));
oos.writeObject(exc);
oos.flush();
oos.close();
System.out.println("OKAY. DataTruncation has been serialized to file: " + args[1]);
System.out.println("DataTruncation value: " + exc.toString());
}
else if ("d".equals(args[0])) {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(args[1]));
DataTruncation obj = (DataTruncation) ois.readObject();
ois.close();
if (exc.getSQLState().equals(obj.getSQLState())) {
System.out.println("OKAY. Deserialization successful.");
System.out.println("DataTruncation value: " + obj.toString());
} else {
System.out.println("FAILED:\n\tExpected:" +
"\n\t" + exc.getSQLState() +
"\n\tReceived: " +
"\n\t" + obj.getSQLState());
}
}
else {
printUsage();
System.exit(1);
}
}
public static void printUsage() {
System.err.println("Usage: java Test [s|d] file");
System.err.println("s - serialize");
System.err.println("d - deserialize");
}
}
--- End-of-Test.java ---
Minimized test output:
=====================
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/javac Test.java
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/java Test s test.ser OKAY. DataTruncation has been serialized to file: test.ser
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/java Test d test.ser OKAY. Deserialization successful.
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/re/jdk/6.0/promoted/beta/b59/binaries/solaris-sparc/bin/java Test s test.ser
OKAY. DataTruncation has been serialized to file: test.ser
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/re/jdk/6.0/promoted/beta/b59/binaries/solaris-sparc/bin/java Test d test.ser
OKAY. Deserialization successful.
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/java Test s test.ser OKAY. DataTruncation has been serialized to file: test.ser
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/re/jdk/6.0/promoted/beta/b59/binaries/solaris-sparc/bin/java Test d test.ser
FAILED:
Expected:
22001
Received:
null
<yg153347@mars> /set/java/re/jdk/6.0/promoted/beta/b59/binaries/solaris-sparc/bin/java Test s test.ser
OKAY. DataTruncation has been serialized to file: test.ser
DataTruncation value: java.sql.DataTruncation: Data truncation
<yg153347@mars> /set/java/jdk1.5.0/solaris-sparc/bin/java Test d test.ser FAILED:
Expected:
01004
Received:
null
Specific Machine Info:
=====================
<yg153347@mars> uname -a
SunOS mars 5.9 Generic_117171-09 sun4u sparc SUNW,Ultra-60
- relates to
-
JDK-6284126 REGRESSION: some java.sql and javax.sql classes changed serialVersionUIDs due to CCC 6283686
- Closed