-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.0
-
sparc
-
solaris_2.5
Name: sdC67446 Date: 06/09/98
methods java.beans.beancontext.BeanContextSupport.
addBeanContextMembershipListener(BeanContextMembershipListener bcml) and
removeBeanContextMembershipListener(BeanContextMembershipListener bcml)
permit 'bcml' == null.
Thus consequent call of fireChildrenAdded/fireChildrenRemoved throws
undocumented NullPointerException if addBeanContextMembershipEvent(null)
has been called previously.
So addBeanContextMembershipListener(null) should throw NullPointerException.
removeBeanContextMembershipListener(null) should throw NullPointerException
for consistency otherwise it should be figured in documentation.
The doc says:
--------------------------------------------------
public void addBeanContextMembershipListener(BeanContextMembershipListener bcml)
Adds a BeanContextMembershipListener
Specified by:
addBeanContextMembershipListener in interface BeanContext
Parameters:
bcml - the BeanContextMembershipListener to add
public void removeBeanContextMembershipListener(
BeanContextMembershipListener bcml)
Removes a BeanContextMembershipListener
Specified by:
removeBeanContextMembershipListener in interface BeanContext
Parameters:
bcml - the BeanContextMembershipListener to remove
Here is the test demostrating the bug:
--------------------------------------------------
import java.beans.beancontext.*;
import java.beans.*;
public class Test extends BeanContextSupport {
public void fireChildrenAddedSpy(BeanContextMembershipEvent bcme) {
super.fireChildrenAdded(bcme);
}
public Test() {
super();
}
public static void main(String[] args) {
Test bcs = new Test();
bcs.addBeanContextMembershipListener(null);
BeanContextMembershipEvent bcme =
new BeanContextMembershipEvent(new BeanContextSupport(),
new Object[0]);
try {
bcs.fireChildrenAddedSpy(bcme);
} catch (Exception e) {
System.out.println("unexpected "+e);
}
try {
bcs.removeBeanContextMembershipListener(null);
System.out.println("nothing happens.");
} catch (Exception e) {
System.out.println("unexpected "+e);
}
}
}
Here is test's output:
--------------------------------------------------
unexpected java.lang.NullPointerException
nothing happens.
--------------------------------------------------
======================================================================