commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 33840] - [beanutils] PropertyUtils.isReadable() and PropertyUtils.getProperty() not consistent
Date Tue, 02 Aug 2005 15:18:56 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33840>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33840





------- Additional Comments From arh14@cornell.edu  2005-08-02 17:18 -------
Furthermore, at least the 1.7 implementation is not sufficiently robust.  For
example, if I try:

PropertyUtils.isReadable(new WrapDynaBean(new Socket()), "inputStream")

returns 'true'.  A subsequent read of this field will yield:

java.lang.IllegalArgumentException: Property 'inputStream' has no read method

PropertyUtils should either inspect DynaBeans in a manner that WrapDynaBean (and
presumably other types of DynaBeans) can modulate (for instance: template
methods DynaBean.isReadable()/isWriteable()) or it should special-case
WrapDynaBean to perform the more thorough PropertyDescriptor test on the
WrapDynaBean.instance() return value:

// Return the requested result
Object realInstance;
if (bean instanceof WrapDynaBean) {
    realInstance = ((WrapDynaBean) bean).getInstance();
} else {
    realInstance = bean;
}
try {
  PropertyDescriptor desc =
      getPropertyDescriptor(bean, name);
  if (desc != null) {
      Method readMethod = desc.getReadMethod();
          if ((readMethod == null) &&
              (desc instanceof IndexedPropertyDescriptor)) {
              readMethod = ((IndexedPropertyDescriptor)
desc).getIndexedReadMethod();
          }
          return (readMethod != null);
      } else {
          return (false);
      }
  } catch (IllegalAccessException e) {
      return (false);
  } catch (InvocationTargetException e) {
      return (false);
  } catch (NoSuchMethodException e) {
      return (false);
  }
}

For that matter, is there a reason the read/write status of a property is not
just part of the DynaProperty structure?



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message