commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (EL-13) Boolean bean property not found due to Introspector limitation
Date Mon, 20 Aug 2007 12:49:30 GMT

    [ https://issues.apache.org/jira/browse/EL-13?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521063
] 

Henri Yandell commented on EL-13:
---------------------------------

Looking deeper at this, I'm not sure there's a bug anymore. The only usage of Introspector
is to get the PropertyDescriptor, and if I use that in the following code, things are good
(under JDKs 1.3->1.5):

import java.beans.*;

public class BooleanPd {

    public static void main(String[] args) throws Exception {
        BeanInfo mBeanInfo = Introspector.getBeanInfo (BooleanPd.class);
        PropertyDescriptor [] pds = mBeanInfo.getPropertyDescriptors ();
        for (int i = 0; pds != null && i < pds.length; i++) {
            PropertyDescriptor pd = pds [i];
            System.err.println(pd.getName());
            System.err.println(pd.getReadMethod());
        }
    }

    public boolean isFlag() { return true; }
    public void setFlag(boolean b) { }

}

This does seems to match Joe's code above though - so maybe the original report hasn't identified
the real issue, suggesting a unit test (or jsp test) is needed.

Thinking more - if this is just a bug for Boolean isXxx and not boolean isXxx, I'm very hesitant
to fix. Joe points out autoboxing in 1.5 suggests Boolean isXxx is legal, but autoboxing also
means that developers shouldn't have any issues with having to do a boolean isXxx method as
they used to.

I think we should WONTFIX. Thoughts?

> Boolean bean property not found due to Introspector limitation
> --------------------------------------------------------------
>
>                 Key: EL-13
>                 URL: https://issues.apache.org/jira/browse/EL-13
>             Project: Commons EL
>          Issue Type: Bug
>    Affects Versions: 1.0
>         Environment: Windows XP, Java 1.5.0_07-b03, Tomcat 5.5.17
>            Reporter: Joe Littlejohn
>             Fix For: 1.1
>
>         Attachments: AdditionalIntrospection.java, AdditionalIntrospection.java, AdditionalIntrospection.java,
AdditionalIntrospection.java, el_exception.txt
>
>
> There is a bug in the java.beans.Introspector which means that it cannot find
> the read method for a property of Boolean type (because it looks for the "get"
> prefix, not the "is" prefix). This is arguably the expected behaviour of the
> Introspector, however since the java.beans.PropertyDescriptor acts differently
> (it can identify the property read method), this inconsistency hints it's a bug.
> Also, with the advent of autoboxing, developers are supposed to be able to free
> themselves from primitive types.
> The commons EL library is affected by this bug, so using an interface like: -
> public interface Bean {
>     Boolean isEnabled();
> }
> and an expression like: -
> ${bean.enabled}
> fails with an ELException saying that the property could not be found (see
> attached log snippet).
> WebLogic does not suffer from this problem, presumably because they implement
> their own EL parser (don't use commons.el) which doesn't use the Introspector. I
> have written a suggested workaround for this problem which would allow the
> commons.el library to continue its use of the Introspector, but deal with this
> flaw (see attached). The AdditionalIntrospection could be used in the
> BeanInfoManager.initialise() method, like so: -
> PropertyDescriptor [] pds = mBeanInfo.getPropertyDescriptors ();
> pds = AdditionalIntrospection.findMissingMethods(mBeanClass, pds); // new step

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message