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

java.beans.VetoableChangeSupport is incorrectly serialized.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2fcs
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Description



      Name: avC70361 Date: 11/14/97



        If an instance of java.beans.VetoableChangeSupport, which has been added an
      instance of VetoableChangeListener for a property name, has been serialized
      into a stream and deserialized back the java.beans.VetoableChangeSupport.
      hasListeners(String) method for that instance with the property name as the
      parameter throws NullPointerException.

      Here is the test demonstrating the bug:
      ------VetoableChangeSupportTest.java----------
      import java.beans.*;
      import java.io.*;

      public class VetoableChangeSupportTest {

        public static void main(String args[]) {

          ObjectOutputStream ostream = null;
          ObjectInputStream istream = null;
          VetoableChangeSupport support = new VetoableChangeSupport(new String());
          support.addVetoableChangeListener(
            "prop",
            new VetoableChangeListener() {
              public void vetoableChange(PropertyChangeEvent evt) {
              }
            }
          );
          support.hasListeners("prop");

          try {

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ostream = new ObjectOutputStream(baos);

            ostream.writeObject(support);
            ostream.flush();

            byte[] array = baos.toByteArray();
            baos.close();

            istream = new ObjectInputStream(
              new ByteArrayInputStream(array)
            );

            ((VetoableChangeSupport)istream.readObject()).hasListeners("prop");

          } catch(Exception e) {
            System.out.println("Exception raised : " + e);
          }
        }

      }

      ---------------------
      Test output
      ---------------------
      #>java VetoableChangeSupportTest
      Exception raised : java.lang.NullPointerException
      ---------------------

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ghamiltosunw Graham Hamilton (Inactive)
              Reporter:
              ovlasov Oleksandr Vlasov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: