Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0 Final
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: PC

      Description

      Overview Description:
      I am trying to use JXPath for accessing properties objects of different
      types. Among the instances that I need to access, are objects of
      implementations that contains methods responding to invokations by throwing
      an Exception. This will cause the JXPath implementation to fail when
      processing XPath expressions like "//property". I have attached an example.

      Would it be possible to alter the JXPath implementation to ignore methods
      that respond to invokations by throwing an Exception?

      Steps to Reproduce:
      Execute the following test class
      -----------------
      import org.apache.commons.jxpath.JXPathContext;

      public class JXPathTestObject {
      public String getException()

      { throw new NullPointerException(""); }

      public void setException(String value){}

      public String getValue()

      { return "value"; }

      public void setValue(String value){}

      public static void main(String[] args)

      { JXPathTestObject object = new JXPathTestObject(); String value = (String)JXPathContext.newContext(object).getValue ("//test"); System.out.println(value); System.out.println("READY."); }

      }
      -----------------

      Actual Results:
      org.apache.commons.jxpath.JXPathException: Cannot access property: exception;
      java.lang.reflect.InvocationTargetException
      at org.apache.commons.jxpath.util.ValueUtils.getValue
      (ValueUtils.java:290)
      at
      org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.getBaseValue
      (BeanPropertyPointer.java:161)
      at
      org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.getLength
      (BeanPropertyPointer.java:149)
      at
      org.apache.commons.jxpath.ri.model.beans.PropertyIterator.setPositionAllProperti
      es(PropertyIterator.java:207)
      at org.apache.commons.jxpath.ri.model.beans.PropertyIterator.setPosition
      (PropertyIterator.java:149)
      at org.apache.commons.jxpath.ri.axes.DescendantContext.nextNode
      (DescendantContext.java:139)
      at org.apache.commons.jxpath.ri.EvalContext.nextSet
      (EvalContext.java:344)
      at org.apache.commons.jxpath.ri.axes.ChildContext.getSingleNodePointer
      (ChildContext.java:113)
      at
      org.apache.commons.jxpath.ri.compiler.Path.getSingleNodePointerForSteps
      (Path.java:175)
      at org.apache.commons.jxpath.ri.compiler.LocationPath.computeValue
      (LocationPath.java:137)
      at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue
      (JXPathContextReferenceImpl.java:204)
      at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue
      (JXPathContextReferenceImpl.java:200)
      at JXPathTestObject.main(JXPathTestObject.java:17)
      Exception in thread "main"

      Expected Results:
      The following written in the console
      ---------
      value
      READY.
      ---------

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Kenneth Petersen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development