You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Alexei Zakharov (JIRA)" <ji...@apache.org> on 2007/01/25 13:29:50 UTC

[jira] Closed: (HARMONY-2526) [classlib][beans] Harmony implementation of PropertyChangeSupport.hasListeners() differs from RI's

     [ https://issues.apache.org/jira/browse/HARMONY-2526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov closed HARMONY-2526.
------------------------------------

    Resolution: Fixed
      Assignee: Alexei Zakharov

> [classlib][beans] Harmony implementation of PropertyChangeSupport.hasListeners() differs from RI's
> --------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2526
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2526
>             Project: Harmony
>          Issue Type: Bug
>          Components: Non-bug differences from RI
>         Environment: winXP
>            Reporter: Alexei Zakharov
>         Assigned To: 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
> import 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.
-
You can reply to this email to add a comment to the issue online.