[classlib][beans] Harmony implementation of PropertyChangeSupport.hasListeners() differs from
RI's
--------------------------------------------------------------------------------------------------
Key: HARMONY-2526
URL: http://issues.apache.org/jira/browse/HARMONY-2526
Project: Harmony
Issue Type: Bug
Components: Non-bug differences from RI
Environment: winXP
Reporter: Alexei Zakharov
Priority: Minor
It seems there is a bug in RI implementation of the java.beans.propertyChangeSupport.hasListeners()
method. It works incorrectly if PropertyChangeListenerProxy was added instead of the regular
PropertyChangeListener. RI cannot find such listeners with hasListeners(). However, the getPropertyChangeListeners()
returns correct value. Please see the test case below:
---I
mport java.beans.*;
public class TestPropertyChangeListener {
public static class MyBean {
public int getProp1() {
return 1;
}
public void setProp1(int val) {}
}
public static class MyListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent evt) {}
}
public static void main(String argv[]) {
MyBean source = new MyBean();
final String prop = "prop1";
PropertyChangeListener l1 = new MyListener();
PropertyChangeListener l2 = new PropertyChangeListenerProxy(prop, new MyListener());
PropertyChangeSupport sup;
sup = new PropertyChangeSupport(source);
sup.addPropertyChangeListener(prop, l1);
System.out.println("Total listeners: " + sup.getPropertyChangeListeners(prop).length);
if (!sup.hasListeners(prop)) {
System.out.println("FAIL at point 1");
}
sup = new PropertyChangeSupport(source);
sup.addPropertyChangeListener(prop, l2);
System.out.println("Total listeners: " + sup.getPropertyChangeListeners(prop).length);
if (!sup.hasListeners(prop)) {
System.out.println("FAIL at point 2");
}
}
}
---
The output on RI is:
Total listeners: 1
Total listeners: 1
FAIL at point 2
Such a behavior is inconsistent and against the spec for PropertyChangeSupport class. Harmony
implementation does not follow it. This test passes on Harmony.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|