JDK-6353846 : REGRESSION: incorrect serialization/deserialization of SQLstate in DataTruncation for 1.5 <-> 6.0
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.sql
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-11-21
  • Updated: 2017-05-16
  • Resolved: 2005-12-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b63Fixed
Related Reports
Relates :  
Description
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

Comments
EVALUATION Please refer to the comments section fro more detials
30-11-2005