You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Matt Benson (JIRA)" <ji...@apache.org> on 2011/06/07 23:53:58 UTC

[jira] [Resolved] (JXPATH-144) Non-existing xpath does not throw exception for LazyDynaBeans

     [ https://issues.apache.org/jira/browse/JXPATH-144?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Benson resolved JXPATH-144.
--------------------------------

    Resolution: Invalid

I understand where you're coming from, but at the same time the very idea of {{LazyDynaBean}} implies that unset properties _are_ real properties whose values happen to be {{null}}.  However, I have committed to trunk a {{NodePointerFactory}} implementation, {{org.apache.commons.jxpath.ri.model.dynabeans.StrictLazyDynaBeanPointerFactory}}, that if installed via {{org.apache.commons.jxpath.ri.JXPathContextReferenceImpl#addNodePointerFactory()}}, will provide the behavior you are looking for.

> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira