You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Mikael Nordenberg (JIRA)" <ji...@apache.org> on 2009/01/29 21:49:59 UTC
[jira] Created: (JXPATH-128) JXPath support for LazyDynaBean is
broken.
JXPath support for LazyDynaBean is broken.
------------------------------------------
Key: JXPATH-128
URL: https://issues.apache.org/jira/browse/JXPATH-128
Project: Commons JXPath
Issue Type: Bug
Affects Versions: 1.3
Reporter: Mikael Nordenberg
The following code throws a "java.lang.NegativeArraySizeException":
LazyDynaBean bean = new LazyDynaBean();
JXPathContext context = JXPathContext.newContext(bean);
Iterator i = context.iterate("anything");
i.hasNext();
Which is due to the fact that in org.apache.commons.jxpath.ri.model.dynabeans.DynaBeanPropertyPointer.getPropertyNames() this code:
boolean hasClass = dynaClass.getDynaProperty("class") != null;
assumes that hasClass is false if there is no property named "class". This is not true for LazyDynaClass (and therefore LazyDynaBean), which documents this feature:
"This implementation has one slightly unusual default behaviour - calling the getDynaProperty(name) method for a property which doesn't exist returns a DynaProperty rather than null. [...] For this reason the isDynaProperty(name) method has been added to this implementation in order to determine if a property actually exists."
So I guess a solution would be to check if it's a LazyDynaClass and check the existance of the property using "isDynaProperty(name)" instead.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (JXPATH-128) JXPath support for LazyDynaBean is
broken.
Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JXPATH-128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matt Benson resolved JXPATH-128.
--------------------------------
Resolution: Fixed
Fix Version/s: post-1.3
Committed revision 739019.
> JXPath support for LazyDynaBean is broken.
> ------------------------------------------
>
> Key: JXPATH-128
> URL: https://issues.apache.org/jira/browse/JXPATH-128
> Project: Commons JXPath
> Issue Type: Bug
> Affects Versions: 1.3
> Reporter: Mikael Nordenberg
> Fix For: post-1.3
>
>
> The following code throws a "java.lang.NegativeArraySizeException":
> LazyDynaBean bean = new LazyDynaBean();
> JXPathContext context = JXPathContext.newContext(bean);
> Iterator i = context.iterate("anything");
> i.hasNext();
> Which is due to the fact that in org.apache.commons.jxpath.ri.model.dynabeans.DynaBeanPropertyPointer.getPropertyNames() this code:
> boolean hasClass = dynaClass.getDynaProperty("class") != null;
> assumes that hasClass is false if there is no property named "class". This is not true for LazyDynaClass (and therefore LazyDynaBean), which documents this feature:
> "This implementation has one slightly unusual default behaviour - calling the getDynaProperty(name) method for a property which doesn't exist returns a DynaProperty rather than null. [...] For this reason the isDynaProperty(name) method has been added to this implementation in order to determine if a property actually exists."
> So I guess a solution would be to check if it's a LazyDynaClass and check the existance of the property using "isDynaProperty(name)" instead.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.