JDK-4092906 : java.beans.VetoableChangeSupport is incorrectly serialized.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 1997-11-14
  • Updated: 1999-01-14
  • Resolved: 1998-07-29
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.
Other
1.2.0 1.2fcsFixed
Related Reports
Relates :  
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
---------------------

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

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.2fcs FIXED IN: 1.2fcs INTEGRATED IN: 1.2fcs VERIFIED IN: 1.2fcs
14-06-2004

EVALUATION Fixed. We now check that child.listeners is non null. graham.hamilton@Eng 1998-05-18
18-05-1998