Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6353846

REGRESSION: incorrect serialization/deserialization of SQLstate in DataTruncation for 1.5 <-> 6.0

    Details

    • Subcomponent:
    • Resolved In Build:
      b63
    • CPU:
      generic
    • OS:
      generic

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                skaushiksunw Shreyas Kaushik (Inactive)
                Reporter:
                ygaevsky Yuri Gaevsky
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: