JDK-4092905 : java.beans.PropertyChangeSupport 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.PropertyChangeSupport, which has been added an
instance of PropertyChangeListener for a property name, has been serialized
into a stream and deserialized back the java.beans.PropertyChangeSupport.
hasListeners(String) method for that instance with the property name as the
parameter throws NullPointerException.

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

public class PropertyChangeSupportTest {

  public static void main(String args[]) {

    ObjectOutputStream ostream = null;
    ObjectInputStream istream = null;
    PropertyChangeSupport support = new PropertyChangeSupport(new String());
    support.addPropertyChangeListener(
      "prop",
      new PropertyChangeListener() {
        public void propertyChange(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)
      );

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

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

}
---------------------
Test output
---------------------
#>java PropertyChangeSupportTest
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