Commons JXPath
  1. Commons JXPath
  2. JXPATH-128

JXPath support for LazyDynaBean is broken.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.4
    • Labels:
      None

      Description

      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.

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              Mikael Nordenberg
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development