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
---------------------
======================================================================