Non-existing xpath does not throw exception for LazyDynaBeans
-------------------------------------------------------------

                 Key: JXPATH-144
                 URL: https://issues.apache.org/jira/browse/JXPATH-144
             Project: Commons JXPath
          Issue Type: Bug
    Affects Versions: 1.3
            Reporter: Mikael Nordenberg


The following code-snippet prints "null" when it should throw an exception:

LazyDynaBean bean = new LazyDynaBean();
JXPathContext context = JXPathContext.newContext(bean);
System.out.println(context.getValue("nonExisting"));


The problem is that in DynaBeanPropertyPointer:

protected boolean isActualProperty() {
        DynaClass dynaClass = dynaBean.getDynaClass();
        return dynaClass.getDynaProperty(getPropertyName()) != null;
}

Returns true, even if the property does not exist in LazyDynaBeans. 
The issue is resolved if the implementation is changed to:

protected boolean isActualProperty() {
        DynaClass dynaClass = dynaBean.getDynaClass();
        if(dynaClass instanceof LazyDynaClass) {
                return 
((LazyDynaClass)dynaClass).isDynaProperty(getPropertyName());
        } else {
                return dynaClass.getDynaProperty(getPropertyName()) != null;
        }
}

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

Reply via email to